- 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
19 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Jayant Gangwar
2022-10-6
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 个评论
更多回答(1 个)
Sambit Supriya Dash
2021-5-7
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));
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!