Why is the "contourf" command plotting my data backwards?
1 view (last 30 days)
Show older comments
MathWorks Support Team
on 14 Apr 2015
Answered: MathWorks Support Team
on 14 Apr 2015
I have data that I would like to plot using MATLAB's "contourf" command. However, when the data is plotted, it is reflected over the y-axis. When I use the "contour" command, it plots normally. Why does "contourf" plot my data backwards?
Accepted Answer
MathWorks Support Team
on 14 Apr 2015
This behavior is a bug that has persisted until R2014a. With the introduction of the HG2 graphics system in R2014b, this issue has since been resolved. Attached is a MAT file with variables that reproduce this issue. The following example uses these variables to generate both incorrect and correct plots from the same code
>> hold on
>> contourf(xksi_mesh,yksi_mesh,strfun);
>> plot(xksi_mesh ,yksi_mesh ,'b');
Incorrect contour plot (R2014a):
Correct contour plot (R2014b):
The workaround to this issue is to use the "fliplr" command to flip all the data from right to left. Doing so yields the correct plot in R2014a and below:
>> hold on
>> contourf(fliplr(xksi_mesh),fliplr(yksi_mesh),fliplr(strfun));
>> plot(xksi_mesh ,yksi_mesh ,'b');
0 Comments
More Answers (0)
See Also
Categories
Find more on Contour Plots 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!