How I can make a chart type COMSOL with matplotlib using 3D ( like tricontourf in 2D ) with different planes?
Asked
Active
Viewed 2,153 times
0
-
So you want to make the two planes intersect in 3D? Unless you post your code (as minimal as possible) no one will be able and willing to help you here – hitzg Nov 12 '14 at 16:01
-
I found now this [Python plot - stacked image slices](http://stackoverflow.com/questions/15582105/python-plot-stacked-image-slices). this is what you like to make but using tricontourf – Josué Daniel Meneses Díaz Nov 12 '14 at 16:12
-
Stop adding links in comments and deleting them later. Post your code. – hitzg Nov 12 '14 at 16:16
2 Answers
0
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()
0
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)