GUI openning a 2y-axis plot in a new window

2 views (last 30 days)
I have a program that reads in data from an impedance analyzer and copies it to the workspace, but it also plots it in the GUI I made (using GUIDE). I have some options in the GUI (like hide one axis, change an axis to log scale, etc.) that work great in the GUI.
However, the plot is stuck in the little GUI window, so I cannot cleanly do a lot of things to it I would be able to do in a new window (mostly zooming and copying). Essentially I have two .m files, one that opens and manages the GUI and one that gets and plots the data from the impedance analyzer. I pass the handles for the two axes and both lines back into the GUI .m file (and use guidata() to update them) and they work fine for what I use them for (changing to/from log scales, hiding lines, etc.).
Currently, I have a button that "opens" both into a new window. I've pasted the relevant code below, but the issue I run into is that it essentially "seperates" the axes so that zooming in on one leaves the other as is and it also refuses to resize the plot. I'm guessing it has something to do with my procedure for just copying both axes individually to the new figure, but I cannot figure out a different way to do this.
function plot_window_Callback(hObject, eventdata, handles);
p2=figure;
copyobj(handles.ax1,p2);
copyobj(handles.ax2,p2);
I've looked for an hour for a single handle to a two y-axes plot as I'm guessing that's the solution, but cannot find one that works properly. In my program ax1 and ax2 are passed around for a while, but initially come from:
[ax, p1, p2] = plotyy(freqs,num1,freqs,num2);
ax1=ax(1); ax2=ax(2); %This step makes slightly more sense with more of my code
Yes, I've also tried plotting just using copyobj(handles.ax,p2) but that doesn't work any better. If I use that method it still has the resizing issue and leaves off the second y-axis's line, although it leaves its scale on the right hand side. I have a feeling the solution has something to do with that, but I'm getting a little frustrated with my current strategy of trying random code until it works.
Huge thanks for any help
  1 Comment
Christopher Dalldorf
Christopher Dalldorf on 23 Jun 2015
Edited: Christopher Dalldorf on 23 Jun 2015
Not sure why it doesn't add new lines in the code i copied...

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 23 Jun 2015
When you want two axes to zoom the same way, you should linkaxes()

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!