-
Notifications
You must be signed in to change notification settings - Fork 58
XY transposable sim.plot() plots (issue1072) #2537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…t(), plot_eps() from simulation.py
Although the basic functionality works (for As Tyler mentioned, there are a bunch of other "plot" functions in the code. I'm going through them to find the ones where I should add a "transpose" argument. |
Let's limit the scope to and yes I think plot limits should also be transposed. You'll see there are some functions that compute vlims and hlims, I think it should be possible to pass Thanks! |
Note to self: At a minimum, I still need to add the
I still need to test:
|
Thanks Tyler!
To clarify, here's a concrete example, plotting a simulation in the XY plane:
It will look like a vertical brick because the vertical limits are bigger than the horizontal limits. Now suppose, we set
In that case, the entire plot will indeed be transposed. (It will look like a brick laid horizontally.) But it also means that the vertical range of the plot will be controlled by |
oh I see what you mean. I think for However, when these values are computed internally (ie when not supplied by user), let's take the transpose into account. Does that seem reasonable? |
Yeah! I'll take a look at that. Thanks! Update:
|
…ources(), plot_monitors(), plot_lumped_elements(), plot_symmetries(), plot_pml(), _get_plot_bounds(), _set_plot_bounds(), plot_arrow(). This code runs without crashing, but there are quite a few weird quirks (things that aren't quite working correctly).
(I just committed the changes that I made to this branch today in order to backup this code. It runs without crashing, but it has some weird quirks, which will require debugging.) Hi Tyler: I don't plan on continuing with this branch today. As I mentioned on slack, I'm going to start a new PR that uses a different approach. (If we decide that approach ultimately works better, we can abandon this PR.) |
I already said this to Tyler in our Slack-chat, but Dario (if you are reading this), here's the reason I am deprecating this PR (for now): There were just too many places in the code where I had to add something like this:
Many different functions and types of plots needed a different "custom thing" . I just wasn't sure in every case that the "custom thing" I was adding was correct. Testing each custom thing I added was hard. I'm about 80% done with creating a newPR which uses a different approach. Going to bed. |
@@ -1184,6 +1211,11 @@ def set_plot_params(boundary_edge, lim, side, thickness): | |||
ax = Box.add_ax_labels_and_title( | |||
ax=ax, x=x, y=y, z=z, plot_length_units=self.plot_length_units | |||
) | |||
if transpose: | |||
import sys | |||
sys.stderr.write( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use raise NotImplementedError(...)
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. (If we decide to continue with this PR, I'll need to come back and fix this part of the code.)
@jewettaijfc actually I think this PR is basically in line with what I expect. The only thing I'm a little confused about is why the new Geometry.transpose_axis_info vs passing Box.add_ax_labels_and_title and handling it there? otherwise I think the if/else complications are simply unavoidable due to the nature of this problem. Although there were a few areas I saw where it could probably be cleaned up slightly for example if transpose:
ax.plot(ys, xs, color=plot_params.facecolor, linewidth=plot_params.linewidth)
else:
ax.plot(xs, ys, color=plot_params.facecolor, linewidth=plot_params.linewidth) could be if transpose:
xs, ys = ys, xs
ax.plot(xs, xs, color=plot_params.facecolor, linewidth=plot_params.linewidth) |
Good suggestion! |
Ahh. Good question. In my first few commits, I added this line at the end of my That is: Whenever I can stop doing that in (The other PR I'm working does not use this pattern.) |
After reading your comment, I also noticed that one of the |
For the record, the other PR is #2544. |
The other PR (#2544 ) is working well and is much further along. I think I will close this PR for now so that people don't get confused. We can always reopen it later if we want to. |
This PR addresses he feature request from issue #1072 (adding the ability to swap the horizontal and vertical axes of a simulation plot).
This includes:
(I'm not yet sure whether I should swap the horizontal and vertical plot limits, because it might confuse the user. Will ask for feedback regarding this detail.)
UPDATE: There is an alternative version of this PR, (PR2544).