[R] ODP: ggplot question

Grzegorz Smoliński g@@mo||n@k|1 @end|ng |rom gm@||@com
Thu Sep 16 08:09:08 CEST 2021


Hi,

of course you can. This should work:

ggplot(s8_plot, aes(fill=GTresult, y=cases, x=gc_label)) +
geom_bar(position="stack", stat="identity")) +
theme(axis.text.x = element_text(angle = 90, hjust = 1))

By "hjust" you make sure that labels do not overlap on plot.

Best regards,

Grzegorz

śr., 15 wrz 2021 o 21:03 Kai Yang <yangkai9999 using yahoo.com> napisał(a):
>
> Hi Grzegorz,
>
> You are correct. it works now.
>
> One more question: can I turn gc_label 90 degree in plot?
>
> Thank you
>
> Kai
>
> On Wednesday, September 15, 2021, 10:54:52 AM PDT, Grzegorz Smoliński <g.smolinski1 using gmail.com> wrote:
>
>
> Hi,
>
> Isn’t a bracket missing after gc_label?
>
> So it should be:
>
> > ggplot(s8_plot, aes(fill=GTresult, y=cases, x=gc_label)) +
>
> +  geom_bar(position="stack", stat="identity"))
>
> Best,
>
> Grzegorz
>
> Od: Kai Yang via R-help
> Wysłano: środa, 15 września 2021 19:50
> Do: R-help Mailing List
> Temat: [R] ggplot question
>
>
>
> Hello List,
>
> I use ggplot to draw a stack bar chart. but I error message. please
> look it below:
>
>
>
> > ggplot(s8_plot, aes(fill=GTresult, y=cases, x=gc_label) +
>
> +  geom_bar(position="stack", stat="identity"))
>
>
>
> Error: Mapping should be created with `aes()` or `aes_()`.
>
>
>
> GTresult and gc_label are character variables, cases is numeric
> variable. How to fix the problem?
>
> Thank you
>
> Kai
>
>
>
>           [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
>
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>
> https://stat.ethz.ch/mailman/listinfo/r-help
>
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list