How to re-scale the Axises when exporting "Values" from binscatter ??

I am using the h= binscatter(x,y,N) with N=250 to plot my data (figure 1 below). After I created it I extract counts=h.Values to plot the contour(counts) - (figure 2 below).. Thus, I have a question. How to rescale my Axises in contour plot (figure 2) to have the same values as on Figure 1????
Many thanks
Figure 1:
Figure 2 ([M,h]=contourf(counts,5);):

 채택된 답변

I'm not sure I understand the question. Have you tried this?
xlim([x1 x2])
ylim([y1 y2])

댓글 수: 5

Sorry didnt get what do you mean. I am not very deep in Matlab,
I need to have the same "real" scales in contour plot like I had in binscatter.
When you extract counts from binscatter plot this is the matrix with the size 250 by 250 with the counts number....
What is a "real" scale?
You can have more contour lines in you contour.
x = randn(1e6,1);
y = 2*x + randn(1e6,1);
N=250;
figure()
h = binscatter(x,y,N)
figure()
d=contour(h.Values,N)
I don't think it's a Matlab problem, bur you need to clearly define what you're trying to achieve.
Sorry that was not very precise. Please look on the intital descrtiption with images! Thanks
I understand now.
You can directly change it using
set(gca,'xtick',xmin:.1:xmax)
Alternatively you can create NxN matrices using meshgrid with the values you need and then plot using contourf
[X,Y] = meshgrid(linspace(xmin,xmax,250),linspace(ymin,ymax,250))
figure()
h = binscatter(x,y,N)
figure()
d=contourf(X,Y,h.Values)
Sergii Snegir
Sergii Snegir 2021년 2월 28일
편집: Sergii Snegir 2021년 3월 1일
Dear Matteo,
thanks for the hint with set(gca,'xtick',xmin:.1:xmax).
I tried to implement it directly but in appears in wrong place and not stretched to the full axis,see image below:

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

질문:

2021년 2월 27일

편집:

2021년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by