does anyone know how to create a back-to-back bar chart with ggplot2?
For anyone who don't know what I am talking about, have a look on a recent paper from the EU (sorry for posting a link, but i think its best to see an example):
I'd like to create plots like the graphs 5,6,18 in the paper.
Moreover due to space constraints I need to draw a second information in one plot (see also the graphs in the paper). I know 2 y-axis plots is not good but sometimes it is better to have eye catching plots with lots of information in it rather than multiple plots :). Is there a way to do such things with ggplot2?
On Thu, Sep 24, 2009 at 1:13 PM, Patrick Wustmann <wustm...@tcd.ie> wrote:
> Hi folk,
> does anyone know how to create a back-to-back bar chart with ggplot2?
> For anyone who don't know what I am talking about, have a look on a
> recent paper from the EU (sorry for posting a link, but i think its
> best to see an example):
> I'd like to create plots like the graphs 5,6,18 in the paper.
> Moreover due to space constraints I need to draw a second information
> in one plot (see also the graphs in the paper). I know 2 y-axis plots
> is not good but sometimes it is better to have eye catching plots with
> lots of information in it rather than multiple plots :). Is there a
> way to do such things with ggplot2?
> Thank you very much.
> Patrick
-- _____________________________
Baptiste Auguié
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
thanks for the reply, No, not really unfortunately. These bars are not
back to back. I need to have two bars on one line 'pointing' in
opposite directions to depict a negative and a positive value on the
same time.
> On Thu, Sep 24, 2009 at 1:13 PM, Patrick Wustmann <wustm...@tcd.ie> wrote:
>> Hi folk,
>> does anyone know how to create a back-to-back bar chart with ggplot2?
>> For anyone who don't know what I am talking about, have a look on a
>> recent paper from the EU (sorry for posting a link, but i think its
>> best to see an example):
>> I'd like to create plots like the graphs 5,6,18 in the paper.
>> Moreover due to space constraints I need to draw a second information
>> in one plot (see also the graphs in the paper). I know 2 y-axis plots
>> is not good but sometimes it is better to have eye catching plots with
>> lots of information in it rather than multiple plots :). Is there a
>> way to do such things with ggplot2?
>> Thank you very much.
>> Patrick
> --
> _____________________________
> Baptiste Auguié
> School of Physics
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
id year com.imp com.exp int.imp int.exp fin.imp fin.exp conf.imp
conf.exp bal
and position_stack(). Plus the geom_line() as a separate layer. Oh,
wait, you might have to manually add the data together -- I'm not sure
if position_stack() works with geom_rect() in the right way...
And yeah, I'd find some other way to do the plot than using a second Y
axis. Probably just a small (short but wide) graph of the second data
set on a separate graph, above or below the main graph. I'm not sure
why they're plotted together on Fig 18 anyway -- the two lines are not
very correlated once you get rid of the linear trend...
-Harlan
On Sep 24, 8:16 am, Patrick Wustmann <wustm...@tcd.ie> wrote:
> thanks for the reply, No, not really unfortunately. These bars are not
> back to back. I need to have two bars on one line 'pointing' in
> opposite directions to depict a negative and a positive value on the
> same time.
> > On Thu, Sep 24, 2009 at 1:13 PM, Patrick Wustmann <wustm...@tcd.ie> wrote:
> >> Hi folk,
> >> does anyone know how to create a back-to-back bar chart with ggplot2?
> >> For anyone who don't know what I am talking about, have a look on a
> >> recent paper from the EU (sorry for posting a link, but i think its
> >> best to see an example):
> >> I'd like to create plots like the graphs 5,6,18 in the paper.
> >> Moreover due to space constraints I need to draw a second information
> >> in one plot (see also the graphs in the paper). I know 2 y-axis plots
> >> is not good but sometimes it is better to have eye catching plots with
> >> lots of information in it rather than multiple plots :). Is there a
> >> way to do such things with ggplot2?
> >> Thank you very much.
> >> Patrick
> > --
> > _____________________________
> > Baptiste Auguié
> > School of Physics
> > University of Exeter
> > Stocker Road,
> > Exeter, Devon,
> > EX4 4QL, UK
Is it not simple a stacked barchart with imports being plottet as negative
values? I dont have time to try it out in ggplot right now - but maybe
later. Guess you have to use stat_identity someway.
It's not easy to read though - that kind of chart. Maybe try with
facet_grid(.~import_export)
On Thu, Sep 24, 2009 at 1:13 PM, Patrick Wustmann <wustm...@tcd.ie> wrote:
> Hi folk,
> does anyone know how to create a back-to-back bar chart with ggplot2?
> For anyone who don't know what I am talking about, have a look on a
> recent paper from the EU (sorry for posting a link, but i think its
> best to see an example):
> I'd like to create plots like the graphs 5,6,18 in the paper.
> Moreover due to space constraints I need to draw a second information
> in one plot (see also the graphs in the paper). I know 2 y-axis plots
> is not good but sometimes it is better to have eye catching plots with
> lots of information in it rather than multiple plots :). Is there a
> way to do such things with ggplot2?
Hm, poking at this a little... I actually like the two-sided bar
charts as a visualization with the surplus/deficit in the middle.
Here's what I came up with as a first stab:
df <- expand.grid(year=seq(1999,2008),
type=c("Commodities", "Intermediate", "Final Products",
"Confidential"),
dir=c("Imports", "Exports"))
p <- p + geom_line(data=df.trade, aes(fill=NULL), color="black",
size=2)
The aes(fill=NULL) is required to prevent a decidedly unhelpful eval
error. For reasons I don't yet understand, the line geom crashes if
you don't override the fill=type aesthetic. And there's no legend for
the Trade line. This may be a case where, if you're generating graphs
for publication, some post-hoc editing may be valuable...
Also, the code gives the following warning, despite working fine:
Warning message:
Stacking not well defined when ymin != 0
Anyone know why it would complain in this case?
-Harlan
On Sep 24, 8:48 am, Andreas Christoffersen <achristoffer...@gmail.com>
wrote:
> Is it not simple a stacked barchart with imports being plottet as negative
> values? I dont have time to try it out in ggplot right now - but maybe
> later. Guess you have to use stat_identity someway.
> It's not easy to read though - that kind of chart. Maybe try with
> facet_grid(.~import_export)
> On Thu, Sep 24, 2009 at 1:13 PM, Patrick Wustmann <wustm...@tcd.ie> wrote:
> > Hi folk,
> > does anyone know how to create a back-to-back bar chart with ggplot2?
> > For anyone who don't know what I am talking about, have a look on a
> > recent paper from the EU (sorry for posting a link, but i think its
> > best to see an example):
> > I'd like to create plots like the graphs 5,6,18 in the paper.
> > Moreover due to space constraints I need to draw a second information
> > in one plot (see also the graphs in the paper). I know 2 y-axis plots
> > is not good but sometimes it is better to have eye catching plots with
> > lots of information in it rather than multiple plots :). Is there a
> > way to do such things with ggplot2?
> Hm, poking at this a little... I actually like the two-sided bar
> charts as a visualization with the surplus/deficit in the middle.
> Here's what I came up with as a first stab:
> p <- p + geom_line(data=df.trade, aes(fill=NULL), color="black",
> size=2)
> The aes(fill=NULL) is required to prevent a decidedly unhelpful eval
> error. For reasons I don't yet understand, the line geom crashes if
> you don't override the fill=type aesthetic. And there's no legend for
> the Trade line. This may be a case where, if you're generating graphs
> for publication, some post-hoc editing may be valuable...
> Also, the code gives the following warning, despite working fine:
> Warning message:
> Stacking not well defined when ymin != 0
> Anyone know why it would complain in this case?
> -Harlan
> On Sep 24, 8:48 am, Andreas Christoffersen <achristoffer...@gmail.com>
> wrote:
> > Hi Patrick,
> > Is it not simple a stacked barchart with imports being plottet as negative
> > values? I dont have time to try it out in ggplot right now - but maybe
> > later. Guess you have to use stat_identity someway.
> > It's not easy to read though - that kind of chart. Maybe try with
> > facet_grid(.~import_export)
> > On Thu, Sep 24, 2009 at 1:13 PM, Patrick Wustmann <wustm...@tcd.ie> wrote:
> > > Hi folk,
> > > does anyone know how to create a back-to-back bar chart with ggplot2?
> > > For anyone who don't know what I am talking about, have a look on a
> > > recent paper from the EU (sorry for posting a link, but i think its
> > > best to see an example):
> > > I'd like to create plots like the graphs 5,6,18 in the paper.
> > > Moreover due to space constraints I need to draw a second information
> > > in one plot (see also the graphs in the paper). I know 2 y-axis plots
> > > is not good but sometimes it is better to have eye catching plots with
> > > lots of information in it rather than multiple plots :). Is there a
> > > way to do such things with ggplot2?
> On Sep 24, 7:45 pm, Harlan Harris <harlan.har...@gmail.com> wrote:
>> Hm, poking at this a little... I actually like the two-sided bar
>> charts as a visualization with the surplus/deficit in the middle.
>> Here's what I came up with as a first stab:
>> p <- p + geom_line(data=df.trade, aes(fill=NULL), color="black",
>> size=2)
>> The aes(fill=NULL) is required to prevent a decidedly unhelpful eval
>> error. For reasons I don't yet understand, the line geom crashes if
>> you don't override the fill=type aesthetic. And there's no legend for
>> the Trade line. This may be a case where, if you're generating graphs
>> for publication, some post-hoc editing may be valuable...
>> Also, the code gives the following warning, despite working fine:
>> Warning message:
>> Stacking not well defined when ymin != 0
>> Anyone know why it would complain in this case?
>> -Harlan
>> On Sep 24, 8:48 am, Andreas Christoffersen <achristoffer...@gmail.com>
>> wrote:
>> > Hi Patrick,
>> > Is it not simple a stacked barchart with imports being plottet as negative
>> > values? I dont have time to try it out in ggplot right now - but maybe
>> > later. Guess you have to use stat_identity someway.
>> > It's not easy to read though - that kind of chart. Maybe try with
>> > facet_grid(.~import_export)
>> > On Thu, Sep 24, 2009 at 1:13 PM, Patrick Wustmann <wustm...@tcd.ie> wrote:
>> > > Hi folk,
>> > > does anyone know how to create a back-to-back bar chart with ggplot2?
>> > > For anyone who don't know what I am talking about, have a look on a
>> > > recent paper from the EU (sorry for posting a link, but i think its
>> > > best to see an example):
>> > > I'd like to create plots like the graphs 5,6,18 in the paper.
>> > > Moreover due to space constraints I need to draw a second information
>> > > in one plot (see also the graphs in the paper). I know 2 y-axis plots
>> > > is not good but sometimes it is better to have eye catching plots with
>> > > lots of information in it rather than multiple plots :). Is there a
>> > > way to do such things with ggplot2?
> On Sep 24, 7:45 pm, Harlan Harris <harlan.har...@gmail.com> wrote:
>> Hm, poking at this a little... I actually like the two-sided bar
>> charts as a visualization with the surplus/deficit in the middle.
>> Here's what I came up with as a first stab:
>> p <- p + geom_line(data=df.trade, aes(fill=NULL), color="black",
>> size=2)
>> The aes(fill=NULL) is required to prevent a decidedly unhelpful eval
>> error. For reasons I don't yet understand, the line geom crashes if
>> you don't override the fill=type aesthetic. And there's no legend for
>> the Trade line. This may be a case where, if you're generating graphs
>> for publication, some post-hoc editing may be valuable...
>> Also, the code gives the following warning, despite working fine:
>> Warning message:
>> Stacking not well defined when ymin != 0
>> Anyone know why it would complain in this case?
>> -Harlan
>> On Sep 24, 8:48 am, Andreas Christoffersen
>> <achristoffer...@gmail.com>
>> wrote:
>>> Hi Patrick,
>>> Is it not simple a stacked barchart with imports being plottet as
>>> negative
>>> values? I dont have time to try it out in ggplot right now - but
>>> maybe
>>> later. Guess you have to use stat_identity someway.
>>> It's not easy to read though - that kind of chart. Maybe try with
>>> facet_grid(.~import_export)
>>> On Thu, Sep 24, 2009 at 1:13 PM, Patrick Wustmann
>>> <wustm...@tcd.ie> wrote:
>>>> Hi folk,
>>>> does anyone know how to create a back-to-back bar chart with
>>>> ggplot2?
>>>> For anyone who don't know what I am talking about, have a look on a
>>>> recent paper from the EU (sorry for posting a link, but i think its
>>>> best to see an example):
>>>> I'd like to create plots like the graphs 5,6,18 in the paper.
>>>> Moreover due to space constraints I need to draw a second
>>>> information
>>>> in one plot (see also the graphs in the paper). I know 2 y-axis
>>>> plots
>>>> is not good but sometimes it is better to have eye catching plots
>>>> with
>>>> lots of information in it rather than multiple plots :). Is there a
>>>> way to do such things with ggplot2?