Wrong axis value in correlation plot

15 views (last 30 days)
Hi, I used correlation plot(corrplot) and getting the following graph. And it is obvious the var2 is bounded by -1 from the two scatter plot and as well as from the data. But the second histogram starts from a starting value much smaller value. I'm not sure is it a bug or my setting problem. Actually I did not do any settings, this is the default output from corrplot.
untitled1.jpg
  2 Comments
the cyclist
the cyclist on 13 Jul 2019
Can you upload your data and code? This would make your problem easier to diagnose.
JT Yang
JT Yang on 13 Jul 2019
Hi, it is simple two columns of data as in the attachment.
command used:
load('matlab.mat')
corrplot(MCMC)
MATLAB R2019A linux version

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 13 Jul 2019
I don't have the Econometrics Toolbox, so I can't confirm myself. But if that is really the only thing you did, then I think this is either a bug or a very unconventional choice on the part of Mathworks. I did this same style plot in R (using the psych library), and the output as you expect it -- with labeling of the figures aligned for both the histogram and the scatterplot. I can't think of a reason to not do it that way.
So, if you are sure that you have not adjusted the scatterplot axes after running the above commands, then I would submit a bug report, including your data and code.
  1 Comment
JT Yang
JT Yang on 14 Jul 2019
Hi, thanks cyclist, I am also testing with Python matplotlib, it seems fine to plot the same type plot.
I'm not sure whether it is a bug or design preference. But I think it is good to share.

Sign in to comment.

More Answers (2)

dpb
dpb on 13 Jul 2019
Edited: dpb on 13 Jul 2019
It's a confusing labeling problem -- the ticks aren't actually the variables on the plot for the histogram but for the scatter plots -- the axes values are for the scatter plot in the upper right quadrant which is scatter(x(:,2),x(:,1)) while the lower left is scatter(x(:,1),x(:,2)).
So, the x-axes limits are for var2 which are bounded at -1; the labels have nothing to do with the histograms; only the scatter plots. TMW just placed the x-axis labels for all the suplots at the bottom instead of keeping them with their respective suplot locations.
If create a poor-man's copy...
subplot(2,2,1)
hist(MCMC(:,1),100)
subplot(2,2,2)
scatter(MCMC(:,2),MCMC(:,1))
ylim([0 0.025])
xlim([-1.105 -0.7])
subplot(2,2,3)
scatter(MCMC(:,1),MCMC(:,2))
xlim([0 0.025])
ylim([-1.105 -0.7])
subplot(2,2,4)
hist(MCMC(:,2),100)
xlim([-1.05 -0.75])
one gets
so, while perhaps confusing, looks like the data are in fact correct...I don't have the Econometrics TB so can't go in and query what the actual limits are on each subplot() but doing so will make things clear, I expect. I fiddled around to roughly approximate the appearance on the LRH one...that took some doing...what the logic is that created the actual limits would be interesting to go look at, perhaps.
  8 Comments
JT Yang
JT Yang on 14 Jul 2019
Hi, dpb. You are superb. I've never dive down so deep into plotting. Now I know how to get the xlim for all graphs. That will be helpful for get around.
dpb
dpb on 15 Jul 2019
One additional note: The line for the diagonal axes that isn't shown is just the variable plotted against itself--the 'ii' case so it is simply a 45-degree line of the range of the variable. The just didn't bother to fix up the logic to not plot the i==j case but did all and then overwrote the diagonal with the histograms not bothering to delete() the extra axes/line.

Sign in to comment.


Amin Salehi
Amin Salehi on 7 Dec 2023
Edited: Amin Salehi on 7 Dec 2023
Yup, I see the same bug (different dataset) the histogram x-axis are wrong.

Categories

Find more on Formatting and Annotation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!