- 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
조회 수: 44 (최근 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에서 Title에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!