ACT
ACT copied to clipboard
Secondary Y axis
@rcjackson @kenkehoe I was looking at adding in a feature for working with a secondary y axis on the timeseries plots, but it is a little more in depth than I thought, mainly due to the set_yrng function. We rely on the subplot indices to set a lot of things and that currently does not include anything about a secondary y-axis. I could put in a work around for now that I think will work, but it's not ideal long-term. Could we adjust the subplot indices at all or are there any other options you could think of?
FYI... I have a very basic secondary y-axis added in, but I do think we need to come up with a better option long-term
@zssherman @mgrover1 I might need to revisit this and see if it's still an issue. I can't remember what exactly I was trying to do with the second y-axis at the time but will try some tests. If you can think of ways we could improve our secondary y-axis handling, I'm all ears!
I would like a better interaction with the secondary y axis plots. Would be nice to have the axis labels match the color of plotted line since we don't need to use a legend. I also have inconsistent results. If I can find some time I will take a look at this.
@kenkehoe One way of copying over the color to the labels could be something such as this:
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 10, 0.1)
y1 = 0.05 * x**2
y2 = -1 *y1
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
p = ax1.plot(x, y1, 'g-')
p2 = ax2.plot(x, y2, 'b-')
ax1.set_xlabel('X data')
ax1.set_ylabel('Y1 data', color=p[0].get_color())
ax2.set_ylabel('Y2 data', color=p2[0].get_color())
plt.show()
I just need to figure out how to implement that in ACT.
@zssherman good idea. I have implemented something similar but not as automated as this in the past. I like your plan. Let me know if you want some help. Implementing this will be used a lot by the DQ Office.
@kenkehoe Awesome! Yeah I think I have an idea on how to implement. Have a parameter like, match_line_label_color or something.
@kenkehoe Revisiting this now, did you want double y axis match colors, just one y match colors?
Have the code in for one, two might not work for now until secondary y is overhauled
Parameter was added for matching color in #632, but will still need to updated secondary y to be more robust.
@zssherman in response to your slack message
I've been playing around with the secondary_y. Can re return two axes one for each y? Or would it conflict with how we are storing multiple datasets in a display object? Trying to think. Ideally we would set a second y with twin_x and set ax2, and customize that axis to represent that y, but currently i'm not sure how to handle it. Maybe like a secondary y kwargs dictionary or something idk
Good question. Right now, when we return the axes info, we just expend it as a 1-d list right? display.axes[0]
We probably should have had this as a 2D array from the beginning but I'm wondering if we could be flexible. I.e. leave as a 1d list but if there is a secondary axis, make it 2D. This would limit the impact to existing users.
@kenkehoe would this break how you are using it in the DQ Office?
@AdamTheisen yes/maybe this would break things. I'm sure we can fix our code for something better.