Skip to content
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

Fix ratio resizing issue #1179

Merged
merged 1 commit into from
Mar 30, 2015
Merged

Conversation

chaosphere2112
Copy link
Contributor

Currently, when you resize a plot that has a ratio in interact() mode, things go badly.

import vcs, cdms2
datafile = cdms2.open(vcs.prefix + "/sample_data/clt.nc")
clt = datafile("clt")

x = vcs.init()
x.plot(clt, ratio="autot")
x.interact()

Here's how the plot looks when you first make it (Perfectly correct)
screen shot 2015-03-27 at 11 57 35 am

Here's how it looks when you shrink the window (Not too bad...)
screen shot 2015-03-27 at 11 57 50 am

But hey, let's compare that to another plot that was actually plotted at that window size, for giggles...

# press "Q", resume execution
y = vcs.init()
# You can plot whatever here, it doesn't matter initially
y.plot(clt)
# Just needed to get the window open...
y.clear()
# Resize to the size of x's window
y.backend.renWin.SetSize(x.backend.renWin.GetSize())
y.plot(clt, ratio="autot")
raw_input("Huh, would you look at that...")

Here's the x canvas' plot:
screen shot 2015-03-27 at 11 57 50 am

Here's the y canvas' plot:
screen shot 2015-03-27 at 11 58 00 am

While we can debate whether the labels should run over each other like that, the second behavior is the "correct" behavior, as the resizing in the first window only happens while in interact mode.

This PR should fix this issue– I looked into it, and plots given a ratio actually already generate a new template. My system was snagging that copied template, and then using it as the basis for a new template. This would cause some cascading error in the resizing logic, which is why the resize came out weird. Since the template is already a copy, I can just add the original and the copy into the existing store of templates. As a happy side effect, the code got a lot shorter and less wacky.

@doutriaux1 @aashish24 Mind taking a look?

@aashish24
Copy link
Contributor

LGTM but I will wait for @doutriaux1 to review since I am not sure if this could open some other issues.

@chaosphere2112
Copy link
Contributor Author

chaosphere2112 commented Mar 27, 2015 via email

@doutriaux1
Copy link
Contributor

LGTM as well, it's much cleaner like this too!

doutriaux1 added a commit that referenced this pull request Mar 30, 2015
@doutriaux1 doutriaux1 merged commit c8ff7e6 into CDAT:master Mar 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants