matlab - 在 MATLAB 中处理多个绘图

标签 matlab plot

我正在使用 plot(X),其中 X 是一个 n×k 矩阵,它使用 生成 k 个图n 点。

如何显示该图的图例?更重要的是,是否有一种简单的方法来显示复选框以显示或不显示某些图?

最佳答案

我认为您会发现这部分文档很有用。
显示表格数据并绘制图表的 GUI
http://www.mathworks.com/help/techdoc/creating_guis/bropmbk-1.html

请将此主体用于 tableplot.m 文件中的 plot_callback 函数,以获取灵活图例的脏实现。

function plot_callback(hObject, eventdata, column)
% hObject     Handle to Plot menu
% eventdata   Not used
% column      Number of column to plot or clear

colors = {'b','m','r'}; % Use consistent color for lines
colnames = get(htable, 'ColumnName');
colname = colnames{column};
lgidx = get(haxes, 'UserData');
if isempty(lgidx)
   lgidx = false(size(colnames));
end

if get(hObject, 'Value')
    % Turn off the advisory text; it never comes back
    set(hprompt, 'Visible', 'off')
    % Obtain the data for that column
    ydata = get(htable, 'Data');
    set(haxes, 'NextPlot', 'Add')
    % Draw the line plot for column
    hplot = plot(haxes, ydata(:,column),...
             'DisplayName', colname,...
             'Color', colors{column});
    lgidx(column) = true;
else % Adding a line to the plot
    % Find the lineseries object and delete it
  hplot = findobj(haxes, 'DisplayName', colname);
  lgidx(column) = false;
  delete(hplot);
end
if any(lgidx)
  legend(haxes, colnames{lgidx} );
else
  legend(haxes, 'off')
end
  set(haxes, 'UserData', lgidx);
end

关于matlab - 在 MATLAB 中处理多个绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11562438/

相关文章:

matlab - 了解符号函数

matlab - 如何将 F# Seq 转换为 MWArray

r - 自定义李克特图中条形图的宽度

绘制海龟与能量的关系图

r - 带有数据点的 barplot() - base R

algorithm - 绘制具有较大值但值变化较小的图形

matlab - 使用 25 个或更少的字符在 MATLAB 中创建特定矩阵

c++ - 从 MATLAB diag(sqrt(v)) 转换为 C++ 中的 Eigen

arrays - 矢量化- Matlab

r - geom_ribbon不起作用-eval(expr,envir,enclos): object 'variable' not found中的错误