I would like to draw a plot like below just exact like image below, How can I do that ?

1 次查看(过去 30 天)

采纳的回答

Thorsten
Thorsten 2016-7-15
x=[1:6];
y=[0.19 0.525 1.175 2.795 7.008 20.210];
ax_invisible=axes('color','none','Ytick',[]);
ax2=axes;
plot(x, y, 'r-')
box off
set(gca, 'xgrid', 'off', 'ygrid', 'on')
title('start/stop time (in seconds)', 'FontWeight', 'bold');
legend('Time')
set(gca,'XTick',1:6,'tickdir','out', 'XtickLabel',[])
xt = arrayfun(@(x) {sprintf('%d', 2.^(x+1) - 1)}, x);
set(ax_invisible,'Xlim',get(ax2,'Xlim'),'XTick',x+0.5,'Xticklabel',xt);
Note that the legend is inside the plot. Positing the legend outside messes things up.
  1 个评论
Shamsed Mahmud
Shamsed Mahmud 2016-7-15
Thank you very much. The answer is 99.5 percent correct and in plot (x+0.5,y,'r-') then it would be 100 percent correct. I like the answer very much.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2016-7-15
plot(x, y, 'r')
legend('Time', 'EastOutside')
title('\bf{start/stop time (in seconds)}', 'interpreter', 'tex');
set(gca, 'xgrid', 'off', 'ygrid', 'on')
  1 个评论
Shamsed Mahmud
Shamsed Mahmud 2016-7-15
Thank you for your answer but I am facing problem about putting the x-axis value where 3 7 15 ... are in the middle in between 1-2 2-3 3-4 5-6 6-7 according to chart and the start should be in the middle of 1-2 like the chart. x=[1:6]; y=[0.19 0.525 1.175 2.795 7.008 20.210]
and in x axis in between 1-2 3 should be set like graph and the graph starts from there.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by