Discussion:
Stacked bar plot filled with symbols/lines
zelfortin
2013-08-01 18:06:42 UTC
Permalink
Hi all,

I have stacked bar plots that I want to fill with symbols/ lines rather
than colors. Here is what my script looks like to fill with colors:

Coul <- c("#990000","#FF3300","#FF6633","#999999","#CCFF99","#33CC00")

Plot1 <- qplot(factor(Model),data=Best,
geom="bar",fill=factor(Best$New.Curve), xlab="Model", ylab="Count") +
labs(title=paste("Best models by country for ", File[e], sep="")) +
scale_fill_manual(values=Coul)

Plot1

So I'm looking to get something more like this:
[image: Loading Image...]

Rather than what I get:


<Loading Image...>

Any help would be much appreciated.

Cheers

JM
<https://lh5.googleusercontent.com/-vQZFiEbK59w/UfqjXBsCMDI/AAAAAAAAAJs/2qnmKmhTzvA/s1600/CF4_BestStack.png>
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Greg Snow
2013-08-01 19:20:55 UTC
Permalink
The human eye-brain combination tends to focus on areas of contrast (change
from one color/shade to another). When you fill boxes with a solid color
(or shade of grey) then the focus is on the boundaries, but when you fill a
box with diagonal lines, hash marks, grids, symbols, etc. then the eye is
often drawn to the contrast within the box rather than the boundary of the
box and this will make it harder for the viewer of the graph to make
meaningful comparisons. This can be a "Fuzzy Box" effect where the size of
the box is not interpreted well. It can even cause a Moire effect where
parts of the plot appear to move, even causing motion sickness in some
viewers (see the book by Tufte).

The use of the diagonal lines and other patterns date back to the days when
the best way to get a color graphic was to use a mechanical pen plotter (a
mechanical arm moved a pen around on the paper) and it was impractical to
completely fill the area (a high density would do it in theory, but it was
really slow (making all the other people waiting to plot something mad) and
often tore holes in the paper). With modern monitors and printers it is
better to use solid fills if you are doing a bar chart.

If you are trying to find an alternative to using color (because you need
to use a black and white medium, or it may be photocopied, etc.) then
consider using a dotplot instead of a barplot, it has a much better data to
ink ratio anyways.

If ggplot2 does not have a means to fill barplots with lines/symbols, then
that should be considered a feature and evidence of well thought out design
rather than any type of lack.
Post by zelfortin
Hi all,
I have stacked bar plots that I want to fill with symbols/ lines rather
Coul <- c("#990000","#FF3300","#FF6633","#999999","#CCFF99","#33CC00")
Plot1 <- qplot(factor(Model),data=Best,
geom="bar",fill=factor(Best$New.Curve), xlab="Model", ylab="Count") +
labs(title=paste("Best models by country for ", File[e], sep="")) +
scale_fill_manual(values=Coul)
Plot1
[image: http://i.stack.imgur.com/62pvM.png]
<https://lh5.googleusercontent.com/-vQZFiEbK59w/UfqjXBsCMDI/AAAAAAAAAJs/2qnmKmhTzvA/s1600/CF4_BestStack.png>
Any help would be much appreciated.
Cheers
JM
<https://lh5.googleusercontent.com/-vQZFiEbK59w/UfqjXBsCMDI/AAAAAAAAAJs/2qnmKmhTzvA/s1600/CF4_BestStack.png>
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/groups/opt_out.
--
Gregory (Greg) L. Snow Ph.D.
538280-***@public.gmane.org
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
zelfortin
2013-08-01 20:09:13 UTC
Permalink
Thanks a lot for your answer,

finally I decided to dodge my stacked bar plot and use a scale of grey
colors. I was afraid that on top of each other they might be hard to
discern, especially since some categories have low values. Here's a final
result:

<Loading Image...>

Here is the script if anyone needs to do something similar :

Plot1 <- ggplot(Data,aes(factor(Model),fill=factor(Data$New.Curve))) +
geom_bar(position="dodge") +
labs(x="Model", y="Count") +
ggtitle(paste("Best models by year for ", File[e], sep="")) +
scale_fill_manual(values=Coul) +
theme_bw() +
theme(axis.title = element_text(size= 18)) +
theme(legend.background = element_rect(fill="grey95"))+
theme(legend.key = element_rect(colour = "grey95",fill="grey95"))+
theme(legend.key.size = unit(1, "cm"))+
theme(legend.text = element_text(size = 15))+
theme(legend.title = element_text(size = 18))+
theme(axis.text = element_text(size = 14))+
theme(legend.margin = unit(1,"cm"))+
theme(axis.title.x = element_text(vjust=-0.5))+
theme(axis.title.y = element_text( vjust=0, angle=90))+
theme(plot.margin = unit(c(1,0.2,2,1), "cm"))+
theme(plot.title = element_text(size=19, face="bold", vjust=2.2))+
theme(panel.grid = element_blank())+
labs(fill="Curve")

Plot1

Cheers

JM
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...