八度图中的附加图例或文本框 window
Additional legend or text box window in a plot in octave
我想在我的绘图中添加带有注释的文本或图例框。
目前我的图例绘制在 northeastoutside,我想将新的图例(或文本框)添加到 southeastoutside 的位置。
谢谢!
缺少有关您的案例的更多信息:
据我所知,一个轴对象只能有一个图例对象。您可以使用第二个坐标区对象创建第二个图例。每个图例将仅列出与每个轴关联的数据元素。改编自 Matlab Newsgroup thread
a = [1:0.01:2*pi]; %create sample data
b = sin(a);
linehandle1 = line(a,b); %creates a line plot with handle object
axeshandle1 = gca; % gets the handle for the axes object just created
legendhandle1 = legend('y = sin(x)', 'location', 'northeastoutside'); %makes first legend
axeshandle2 = axes('Position',get(axeshandle1,'Position'),'xlim',get(axeshandle1,'xlim'),'ylim',get(axeshandle1,'ylim'),'Visible','off','Color','none'); %makes invisible axes with same position and scaling
linehandle2 = line(pi/2,1,'Color','r','Marker','o','Parent',axeshandle2); %puts data set on 2nd axes
linehandle3 = line(pi,0,'Color','b','Marker','x','Parent',axeshandle2);
legend_handle2 = legend('peak','zero','location','southeastoutside'); %creates legend to go with 2nd axes
如果您只想要第二个框中的文本,不一定是图例信息或数据标签,您可以如上所述使用注释。这具有调用更简单的优点,但可能更难获得您想要的确切 position/result。有大量 属性 选项可以调整以获得所需的外观。示例中显示了一些。可能有更简单的方法可以根据图例句柄设置 size/position。
a = [1:0.01:2*pi]; %create sample data
b = sin(a);
plot(a,b);
legendhandle = legend('y = sin(x)','location','northeastoutside');
annotation('textbox',[0.875 0.1 0.1 0.1],'string','my text','edgecolor','k','linewidth',1,'fitboxtotext','off');
我想在我的绘图中添加带有注释的文本或图例框。
目前我的图例绘制在 northeastoutside,我想将新的图例(或文本框)添加到 southeastoutside 的位置。
谢谢!
缺少有关您的案例的更多信息:
据我所知,一个轴对象只能有一个图例对象。您可以使用第二个坐标区对象创建第二个图例。每个图例将仅列出与每个轴关联的数据元素。改编自 Matlab Newsgroup thread
a = [1:0.01:2*pi]; %create sample data
b = sin(a);
linehandle1 = line(a,b); %creates a line plot with handle object
axeshandle1 = gca; % gets the handle for the axes object just created
legendhandle1 = legend('y = sin(x)', 'location', 'northeastoutside'); %makes first legend
axeshandle2 = axes('Position',get(axeshandle1,'Position'),'xlim',get(axeshandle1,'xlim'),'ylim',get(axeshandle1,'ylim'),'Visible','off','Color','none'); %makes invisible axes with same position and scaling
linehandle2 = line(pi/2,1,'Color','r','Marker','o','Parent',axeshandle2); %puts data set on 2nd axes
linehandle3 = line(pi,0,'Color','b','Marker','x','Parent',axeshandle2);
legend_handle2 = legend('peak','zero','location','southeastoutside'); %creates legend to go with 2nd axes
如果您只想要第二个框中的文本,不一定是图例信息或数据标签,您可以如上所述使用注释。这具有调用更简单的优点,但可能更难获得您想要的确切 position/result。有大量 属性 选项可以调整以获得所需的外观。示例中显示了一些。可能有更简单的方法可以根据图例句柄设置 size/position。
a = [1:0.01:2*pi]; %create sample data
b = sin(a);
plot(a,b);
legendhandle = legend('y = sin(x)','location','northeastoutside');
annotation('textbox',[0.875 0.1 0.1 0.1],'string','my text','edgecolor','k','linewidth',1,'fitboxtotext','off');