How to plot x=0 in semilogx plot?

本秂侑毒 提交于 2019-12-06 14:16:56

Usually, what is done in cases like this is adding 1 to all x, so the first value (originally 0) appears at the origin, and also the back-transformation is the same for all values. You can add any other small values than 1, and get a similar result. However, you don't want to add a value that is too small (like eps) because then you get a huge distance from the next value, that will cause all other values to pack on the right side of the graph.

Let's look at an example:

x = [0 logspace(0,2,5)];
% x =  0    1    3.1623    10    31.623    100
y = 2.*(x+1); % add 1 to all x
semilogx(x+1,y,'o','markerfacecolor','b') 

While if you replace 0 with eps you get:

x = [0 logspace(0,2,5)];
y = 2.*(x+eps); % add a tiny value too all x
semilogx(x+eps,y,'o','markerfacecolor','b')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!