Search code examples
matlabplotgraphlogarithm

How to plot unevenly spaced data on Matlab / Origin?


I want to plot my following data:

x-axis: [0,10,50,100,500,1000,1500]
y-axis: [75.6,78,78.2,81.8,84.7,85.2,86.3]

As seen above, the data on the x-axis are unevenly spaced. When I plot the above data linearly using origin, I get: enter image description here

I got the similar graph on Matlab too. Notice that most of the Amp data lie for x<500. I want to plot the graph such that the whole output (y-axis) become clearly visible. For this, I tried using the Logarithmic plot. I changed the x-axis into logarithmic in Matlab as follows:

set(gca, 'XScale','log');

In Origin, we can use GUI to change the x-axis to logarithmic. The obtained graphs are as follows:

Origin graph

Matlab plot

The obtained graphs are still not good. Any ideas, please!

Thank you very much.


Solution

  • https://www.mathworks.com/help/matlab/ref/semilogx.html

    x = [0,10,50,100,500,1000,1500];
    y = [75.6,78,78.2,81.8,84.7,85.2,86.3];
    semilogx(x,y,'.-', 'markersize', 15);
    set(gca,'XTick',x);
    set(gca,'XTickLabelRotation',45);