Just one y axis is drawn in GUI when I use the plotyy.

3 次查看(过去 30 天)
Hello, I have questions about 'plotyy'.
For example, code is like this in 'plotting_graph.m'. It is used for drawing graph.
[hAx, hLine1, hLine2] = plotyy(axis_x, (table(:, 1)/scale_value), axis_x, table_cumsum(:, 2));
And, at 'graph.m'(GUI code) I intend to enlarge the figure when I click the right button on mouse.
but when I click the right button, only one y axis is exist on the enlarged figure window.
function plot_ax1_Callback(hObject, eventdata, handles)
% Displays contents of axes1 at larger size in a new figure
global plotyy_flag;
if (plotyy_flag == true)
axes1fig = figure;
% Copy the axes and size it to the figure
axes1copy = copyobj(handles.axes1,axes1fig);
set(axes1copy,'Units','Normalized', 'Position',[.05,.2,.9,.6]);
set(axes1copy, 'FontSize', 9);
hold on;
% Save handles to new fig and axes in case
% we want to do anything else to them
handles.axes1fig = axes1fig;
handles.axes1copy = axes1copy;
guidata(hObject,handles);
end
how can I bring the 2 yyaxis on the new figure window? please help me.
when I use the 'guidata(hObject, handles)', it doesnt't work.

采纳的回答

Henry Giddens
Henry Giddens 2017-9-16
编辑:Henry Giddens 2017-9-16
Hi,
plotyy creates two axes objects. You need to copy both to the new figure. Are you sure that your code is copying both objects? Is 'handles.axes1' a single axes object or does it contain 2 entries?
You should have both axes objects in hAx from the first line of code:
[hAx, hLine1, hLine2] = plotyy(axis_x, (table(:, 1)/scale_value), axis_x, table_cumsum(:, 2));
Make sure you are copying both objects in hAx to the new figure
  1 个评论
octopus_love
octopus_love 2017-9-18
Thanks. Maybe, It is because of the dealing with 2 handles on the axes. My solution is : making the axis information(hAx) to global variables. And I used it the 'plot_ax1_Callback'.
Many thanks to advice me.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Two y-axis 的更多信息

Community Treasure Hunt

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

Start Hunting!