[Question] Can sec_axis be used to add more than one secondary axis?
63 views
Skip to first unread message
Parker Golliglee
unread,
Aug 12, 2022, 12:02:35 AM8/12/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
I am trying to plot data from USGS stream gages and would like to include discharge, temperature and turbidity over time. These all use different scales so I would like to add 2 additional y-axis. I have fooled around a little, and have successfully added a secondary axis, but I can not get a tertiary axis to graph as well. I would really like to do this in ggplot2 as I plan to animate this figure as a part of a presentation. Thank you in advance for your help.
Oliver Lee
unread,
Aug 15, 2022, 8:24:08 AM8/15/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
You can just add a vertical line as the third axis: geom_vline()
For the number you need to scale it to be in line with the primary axis.
Parker Golliglee
unread,
Aug 24, 2022, 12:26:25 PM8/24/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
unfortunately I was not able to get this solution to work, I would like the third axis to extend outside of the plot, beyond the first and have its own title and scale. I may just be unsure of how to do this with geom_vline(), but I was unable to add a line outside of my plot.
Oliver Lee
unread,
Aug 27, 2022, 7:26:06 AM8/27/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
The likely solution is to extend your xlim and put the third vertical line inside the plot.
It can have its own scale as long as you adjust the number in respective data seiries.