MATLAB Answers

0

Why is the "contourf" command plotting my data backwards?

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?

Products


Release

R2013a

1 Answer

Answer by MathWorks Support Team on 14 Apr 2015
 Accepted Answer

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

Sign in to comment.