Plotting in 2D - hlep with axes

Hello everyone! I'm tring to plot in 2D a couple of curves, but the problem is that the "x" axis behaves weirdly. So from 0 to 1 the scale goes just linear, but from 1 onwards (until infinity) the escale is 1/x. This means that if i divide the scale of the x axis each 0,2 points i would have something like:
0 0.2 0.4 0.6 0.8 1 (until here just linear) 0.8 0.6 0.4 0.2 0 (0 would be infinity because 1/x when x=0 ->inf)
And i have no idea how to plot this!
Any help is welcome
thankss

2 Comments

this is the graph that I'm trying to plot
But the 1:5 marks on the lower axis don't match with 1/n on the other -- they're just linearly spaced from the centerline.
I don't see what bearing they have on the other; 1/5 would be 0.2 which would be farther to right; in fact all 5:-1:2 would be before reaching between 0.2 - 0.5 if that were the intent. Doesn't make any sense to me standing alone; I presume there's some other explanation that goes along with the figure that would explain the correlation but doesn't look to me that it takes anything but a second linear axes to replicate the figure itself; the nonlinear issue just isn't actually drawn.

Sign in to comment.

Answers (1)

There is no way I know of to apply two different scales to the x axis. That means you would have to modify the underlying data, and/or manually updating the axis labels.
You haven't shared an equation or data to test with, so here's a trivial example that just updates the axis labels.
xPlotting = 0:0.2:2;
y=[0 0.01 0.1 0.5 2 10 2.3 1.5 1.25 1.1 1];
plot(xPlotting,y)
xticks(xPlotting)
xticklabels([0 0.2 0.4 0.6 0.8 1 0.8 0.6 0.4 0.2 0])
grid on

Asked:

on 24 Nov 2022

Commented:

dpb
on 24 Nov 2022

Community Treasure Hunt

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

Start Hunting!