Manipulating axes (position scales) for continuous and discrete data in ggplot2 (CC154)

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ก.ค. 2024
  • ggplot2 allows you to manipulate the appearance of axes - also called position scales - on your x and y axes for displaying continuous and discrete data. This episode of Code Club will show you how you can use various options in scale_x_continuous/scale_y_continuous and scale_x_discrete/scale_y_discrete to modify their appearance. With these functions, Pat also describes how they differ from coord_cartesian and xlim/ylim/limits and how to modify the padding at the ends of the axes using the expand argument and expansion helper function. The data depict the percentage of people in 15 countries who would be willing to receive the COVID-19 vaccine as of August and October of 2020.
    In this episode, Pat uses #RStudio, #GitHub, and #git. The accompanying blog post can be found at www.riffomonas.org/code_club/....
    Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at shop.riffomonas.org/youtube to get practice problems, tips, and insights.
    R: r-project.org
    RStudio: rstudio.com
    Workshops: www.mothur.org/wiki/workshops
    If you're interested in taking an upcoming 3 day R workshop be sure to check out our schedule at riffomonas.org/workshops/
    You can also find complete tutorials for learning R with the tidyverse using...
    Microbial ecology data: www.riffomonas.org/minimalR/
    General data: www.riffomonas.org/generalR/
    0:00 Types of data we can represent on axes
    2:31 Using scale_x_discrete (or scale_y_discrete)
    5:14 Using scale_y_continuous (or scale_y_continuous)
    7:59 What about coord_cartesian and xlim/ylim/limits?
    10:58 Changing the padding at the ends of the axes
    14:14 Critique of axes
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 15

  • @Riffomonas
    @Riffomonas  2 ปีที่แล้ว +2

    Believe it or not, I didn't actually cover everything there is to know about scale_x/y_discrete and scale_x/y_continuous. What else would you like to know about manipulating your axes?

  • @yacksumusha
    @yacksumusha 2 ปีที่แล้ว +1

    You just made me figure out how to get unstuck in my data viz project. Thank you!!!

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว

      Wonderful! Thanks for watching Amadeu 😊

  • @GardenCityHomestead
    @GardenCityHomestead 2 ปีที่แล้ว +1

    You must have read my mind! I needed this information very much! I don't think I knew the correct terms to search for ... or else there isn't any decent info out there on this. Thank you!

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว +1

      Wonderful! Did you find this by search? What terms did you use? I think “scales” is not super intuitive as a way to manipulate axes

    • @GardenCityHomestead
      @GardenCityHomestead 2 ปีที่แล้ว +1

      @@Riffomonas I am subscribed to you. I found it because it showed up on my feed. I had been searching TH-cam for "r axis" + any other terms I could think of. I used to be a Sr. Business Information analyst for Pfizer before my daughter was born. I am updating my skills now to get back into the field. I find your videos thorough and easy to follow. Thank you!

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว

      Very cool - thanks for the insight! If you come across any Interesting datasets from your world, feel free to share! I’d love to expand the audience more beyond biologists

  • @VictorPerez-jy9lf
    @VictorPerez-jy9lf 2 ปีที่แล้ว +1

    Hello sir!! Thank you very much for the video, a question.
    When transposing my axes in a bar chart with coor_flip() and adjusting the configuration of my new axes and executing geom_shadowtext()..... I get the following error, Error: Discrete value supplied to continuous scale, how could I execute my bar graphic?

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว +1

      Are you using scale_*_continuous vs scale_*_discrete? I’d check there by making sure you’re using the right function for the right axis. I find it is typically easier in the long run not to use coord_flip

  • @md.masumbillah8222
    @md.masumbillah8222 2 ปีที่แล้ว +1

    Hi FOR my case it came with that error 'Scale for 'y' is already present. Adding another scale for 'y', which will replace the
    existing scale" while i was trying to break y axis at some point. DO YOU have any advise, thanks

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว +1

      HI! The general advise from data visualization practitioners is to not break an x- or y-axis since it can be deceiving to the audience. It is better to pick limits and comparisons that make it unnecessary. Based on this advice, ggplot2 makes it pretty hard to achieve.

  • @ndipagbor7280
    @ndipagbor7280 2 ปีที่แล้ว +1

    Video saved.

  • @russtin1
    @russtin1 2 ปีที่แล้ว +3

    Keep peeling that ggplot onion

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว

      my eyes are watering! 😂