cis-ds / Discussion

Public discussion
10 stars 15 forks source link

Issues of drawing two graphs in hw2 using R #201

Closed BaichenTan closed 2 years ago

BaichenTan commented 2 years ago

How can I set the y-axis like this in R code? They are of unequal length WechatIMG48 ?

How can I using facetwrap while setting different binwidth for each graph in this pic ![501655674993 pic](https://user-images.githubusercontent.com/107418876/174502008-30dd3d15-df50-43fe-be95-3dfb483908d9.jpg) ? @bensoltoff

BaichenTan commented 2 years ago

I figured out that the first graph requires us to rescale the yaxis in log scale, adding the function scale_y_continuous() to our codes, but I am still confused of how we can make the second graph by using facet_wrap, what other functions should we use to set different binwidth for each sub-graph? Currently I create three distinct pictures and use ggarange to combine the three graphs into one graph, but I think that method is quite tedious so I thought there will be a simple way (just using facet_wrap) to realize this result.

bensoltoff commented 2 years ago

For the second graph, you can do it in a single plot with faceting. The binwidth had not changed between each of the panels. Instead the range of the x axis has changed between each panel. Look at the documentation for facet_wrap() and see what argument allows you to vary the range of the x or y axes.