Python Forum
Reproduce Minitab contour plot with Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reproduce Minitab contour plot with Python
#1
Hi guys!
I've got a problem that I am not able to fix. I did not find an answer that comes close to my problem.
Starting point:
Three arrays : X, Y, Z describing values for a plot.
I want to do a contour plot using them. (Contourf in Python)
My reference plot is created by the software Minitab.
My code for plotting in python is something like this:

#x,y,z as input
xgrid = np.linspace(x.min(), x.max(), 200)
ygrid = np.linspace(y.min(), y.max(), 200)
X,Y = np.meshgrid(xgrid, ygrid)
Z = griddata(x,y,z,X,Y)
plt.figure()
plt.contourf(X,Y,Z)
plt.show()
Apart from the number of levels of the contour plot, the python plot looks somehow distorted compared to the Minitab output. I want to adapt the python plot to the minitab output, but I don't know why.
The example figures for both plots can be found in the attached files

Can somebody help me please?

(Yes, the dimensions are not similar, but this is not the reason for the "peaks" in the python version, in my opinion, and does not matter)

[Image: minitabcontour.png.html]
[Image: pythoncontour.png.html]

Thanks a lot!
Benny
Reply
#2
Try to insert

ax = plt.gca()
ax.set_aspect(1.0/ax.get_data_ratio())
after contourf.

Also, it would be helpful to consider zoooming for smoothing contour lines.
Reply
#3
Thank you for your answer!
Unfortunately, your suggested commands do not lead to the desired output either.
Somehow, I think I have managed to find out what the reason for the different plots is:
Minitab apparently does standardize the x- and y-axis. In my case, the x axis dimension is much higher than the y-axis dimension. Consequently, the interpolation mainly interpolates in y-axis direction, which leads to these "peaks" in vertical direction.
Perhaps minitab is somehow standardizing this, so that it is less "stretched" in y-direction.
Does this make sense? Is there a possibility to get the same process into python?

Best regards
Reply
#4
I didn't work with minitab and I don't know how it builds filled contour plots.
Could you provide your data: x, y and z, I would like to play with it.
May be minitab make contour plot in logarithmic-scale?...
Reply
#5
Hi Scidam,
thanks for your answer.
I've managed to reproduce the minitab plot with python now.
The problem was, as I've already guessed, the scaling of the x and y axis. After converting the axes to consistent units, the plots assume a structure like minitab is showing. Consequently, my problem is solved so far.
However, I still did not find out, how Minitab is processing the information without having information about the units etc. It somehow normalizes the x and y data, but the minitab documentation does not tell why and how this is done.

Best regards and thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Three-dimensional Contour Plots minifizikus 1 3,268 Sep-13-2018, 10:56 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020