Re: histogram with color fill, abbreviated names in blocks, and full names in the legend

86 views
Skip to first unread message

Ista Zahn

unread,
Jan 30, 2013, 4:40:34 PM1/30/13
to davideps, ggp...@googlegroups.com
Hi David,

You tell geom_text to use the sf_dataset. Is there a abbr column in
df_dataset? You only say there is such a variable in enf_dataset.

Hope this helps,
Ista

On Wed, Jan 30, 2013 at 4:15 PM, davideps <davi...@umich.edu> wrote:
> Hello,
>
> I create a histogram with the following commands:
>
>>dev.new()
>>gplot() + geom_histogram(aes(y = ..count..,x = market_score,fill =
>> filename),data=enf_dataset) + facet_grid(facets = year ~ .)
>
> The "enf_dataset" has a text column named "abbr" that I want to use to label
> each box in the histogram. I would then like the legend to show in
> alphabetical order:
>
> abbr1: filename1
> abbr2: filename2
> etc.
>
> But, I receive an error that the label aesthetic is missing whenever I try
> to add a layer like this to the plot:
>
>>geom_text(aes(x = market_score, label=abbr),data=sf_dataset,stat = 'bin')
>
> Note that I used JGR+deducer to help write the ggplot code. Any help would
> be appreciated.
>
> -david
>
> --
> --
> 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 ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> 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+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Ista Zahn

unread,
Jan 30, 2013, 5:31:22 PM1/30/13
to davideps, ggp...@googlegroups.com
Ah, sorry I didn't pick up the the key part of the question earlier. I
don't think what you propose will work, because it's not clear where
the labels should go. But there error message wasn't very helpful!

Maybe if you explain in more detail what you are trying to accomplish,
and provide a reproducible example (see
https://github.com/hadley/devtools/wiki/Reproducibility for help with
this) we can point you in the right direction.

Best,
Ista




On Wed, Jan 30, 2013 at 4:56 PM, davideps <davi...@umich.edu> wrote:
> Yes, sorry for that unnecessary complication. All datasets have the "abbr"
> column. Perhaps more simply, how could I get this to work:
>
>> dev.new(); ggplot() + geom_text(aes(x =
>> sf_units,label=abbr),data=sf_dataset,stat = 'bin') + facet_grid(facets =
>> year ~ .)
> stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
> stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
> stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
> stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
> stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
> Error: geom_text requires the following missing aesthetics: label
>
> Yet:
>
>>sf_dataset$abbr
> [1] "Bell" "Bell" "Bell" "Bell" "Bell" "Buck" "Buck" "Buck" "Buck" "Burt"
> "Burt" "Burt" "Burt" "Coll" "Coll" "Coll" "Coll" "Cude" "Detr" "Detr" "Detr"
> "Fair" "Fair" "Fair" "Fami" "Fami"
> etc
>
> Any ideas? And will the "y" automatically be assigned to "count" when
> stat='bin'?
Reply all
Reply to author
Forward
0 new messages