facet wrap

136 views
Skip to first unread message

paulniyi

unread,
Jul 27, 2024, 12:35:47 AM7/27/24
to ggplot2
please how can I make a ggplot of facet wrap for this data

AntibioticsYear2016Year2017Year2018Year2019Year2020Year2021Year2022
GN443242608692374296413
STR68346310
CFX410132426731578396372
CFZ257116331465438126283
CTZ25274321388341244245
CEF0351131159
CXT00006256314
CFP002222188264235
OFX162109212229238178262
CIP10448117102127102139
LEV0062439393
CXC3291845522893900
AMP12363411128
AUG337133336508392423470
AZT000012251
ERY43121169167217996149
NIT3225422
TET2132111
COT0000211
IMP00022275102



avi.e...@gmail.com

unread,
Jul 27, 2024, 2:17:00 AM7/27/24
to paulniyi, ggplot2

Paul,

Facet_wrap() and a few relatives are the end of a process and you left out the rest of what you want.

You need to first have multiple lines of code that would make some kind of graph using ggplot(...) + geom_line(...) and so on first and then use facet_wrap(...), with appropriate arguments, to specify a formula that results in making multiple plots that vary depending on what you want.

In many cases, you would need to first change the format of your data such as condensing Year2016 through Year2022 into long format so that you have a field like "YEAR" and another like "VALUE" and then work on it.

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ggplot2/d13cff0f-e97d-4c2e-b84f-eb6c900c76fen%40googlegroups.com.

Muhammad Zubair Ishaq

unread,
Sep 14, 2024, 11:13:18 PM9/14/24
to ggplot2
Here you can find
Rotate ggplot2 Axis Labels in R: Improve Plot Readability
Learn Master ggplot2 axis label rotation in R for clearer visualizations. Learn to rotate x and y-axis labels to any angle and avoid overlaps
The theme() function and axis.text.x control
Think of the theme() function as your ggplot2 customization central. It lets you tweak all sorts of visual stuff, including tick labels and their positioning. Within theme(), the axis.text.x element specifically targets your x-axis labels. This is where the rotation magic happens!
Step-by-step code example
Let's use our iris scatterplot from earlier:
ggplot(df, aes(x = long_labels, y = response)) + geom_point() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))

Read more ggplot rotate axis labels
Reply all
Reply to author
Forward
0 new messages