- Add a data tip at a point
- Right click on the data tip which will open a pop up menu, select the option "Edit Content and Style"
- In the "Data Tip Content -> DataTipRows" section click on "X", this will open properties of the x-axis datatip
- Now set the value you want to be displayed in the "Value" field, in above example it would be vector A
- Now whenever you will select a point in the graph, it will show the value of x not 1/x
How to plot with a reciprocal (1/x) scale
24 views (last 30 days)
Show older comments
Maruan Alberto Bracci
on 3 May 2021
Answered: Jayant Gangwar
on 6 Oct 2022
Hi everybody,
I have some sets of data: [x1] and [y1], [x2] and [y2], ...The x axes have been obtained by calculating (with a complex operation) the reciprocal of the sets [A], [B], ...When I plot x1 vs y1, x2 vs y2, ... the data points are no longer equally spaced in the plot (very crowded at one side of the plot). Something like that:
A = linspace(1,50,100);
B = linspace(10,70,80);
x1 = 1./A; %semplified version of the real calculation
x2 = 1./B;
y1 = rand(100,1);
y2 = rand(80,1);
plot(x1,y1,'-o',x2,y2,'-o')
What I need is
- that the data points are equally spaced
- that the labels of the horizontal axis correspond to x
- when a point from the graph is selected, it shows the value of x and not 1/x.
What I did to solve the point 1 is plotting 1./x1 and 1./x2.
plot(1./x1,y1,'-o',1./x2,y2,'-o')
To solve point 2, I have used 'Xtick' and 'XTickLabel' to manually set the labels. I found no solution to point 3. I would like to use something like semilogx, but for reciprocal scales. Does it exist?
Thx for your time
0 Comments
Accepted Answer
Jayant Gangwar
on 6 Oct 2022
Hi Maruan,
To achieve your 3rd point you can edit the content being displayed using the UI in the figure.
The steps to do so are -
0 Comments
More Answers (1)
Sambit Supriya Dash
on 7 May 2021
Supposing this example from the MATLAB previous codes,
A = [0.5,0.65,0.7,0.66,0.81]; % The plotting function values
B = [5,10,20,100,1000]; % The x-axis levels
plot(A);
xticks(1:length(A));
xticklabels(string(B));
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!