简体   繁体   中英

How to make a matplotlib to plot a 3D tricontour?

How I can make a chart type COMSOL with matplotlib using 3D ( like tricontourf in 2D ) with different planes?

示例图

example chart COMSOL

Sorry for adding links in comments and deleting them later this is my first question...

This is the code that I using to plot 2d. I have a matrix with 4 columns:

fig, ax = plt.subplots(1); fig.set_figwidth(17); fig.set_figheight(7);

    x = a[:, 0]; 
    y = a[:, 1]; 
    t = a[:, 3];

    fig_1 = ax.tricontourf(x, y, t); 
    ax.tricontour(x, y, t, colors = 'k'); ax.scatter(x, y)
    ax.set_xlabel("Eje y [mm]", fontsize = 20); ax.set_ylabel("Eje x [mm]", fontsize = 

plt.show()

but when I try to make plans in 3d it does not work, the color layers are separated:

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure()
ax = fig.gca(projection='3d')

cset = ax.tricontourf(x, y, t, zdir= 'z', cmap=cm.coolwarm)
fig.colorbar(cset)

plt.show()

I had the same problem. Simply set offset to some z value.

cset = ax.tricontourf(x, y,t,  zdir= 'z', cmap=cm.coolwarm,offset=1.0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM