Matplotlib separate 2D contour projection plots of 3D data

GafferMan2112

I am trying to create 2D plots of the projection of 3D data. Very simply, based on this example is there a way to produce the three contour projections shown (in the X, Y, and Z directions) as separate 2D plots? I can easily create the contour projection in the Z direction by using the pyplot 'contour' command, but only the '3d' projection 'contour' command seems to be able to take the 'zdir' parameter, and it can't create 2D plots.

tom10

The zdir parameter in a 3D contour basically says which axis will be used to determine the contour levels in a 3D plot. In a 2D plot this is usually specified by the order of the arguments, so what we normally think of as "Z", that is, the values that determine the contour level, is put in as the third argument. In the example below, note in particular the first three arguments in each of the contourf calls:

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

X, Y, Z = axes3d.get_test_data(0.05)

plt.subplot(131)
cset = plt.contourf(X, Y, Z, cmap=cm.coolwarm)
plt.subplot(132)
cset = plt.contourf(Y, Z, X, cmap=cm.coolwarm)
plt.subplot(133)
cset = plt.contourf(X, Z, Y, cmap=cm.coolwarm)

plt.show()

enter image description here

Compared to the projections in the 3D plot:

enter image description here

Note that here I've referred to "the third argument", but there are actually lots of ways that the arguments to contourf can be interpreted, so see the docs for more details, although this approach will generally only work with calls where X, Y, and Z are explicit.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

3D histograms and Contour plots Python

From Dev

Python 2D plots as 3D (Matplotlib)

From Dev

plot multiple 2d contour plots in one 3d figure [Matlab]

From Dev

matplotlib 3d surface plots not showing

From Dev

Matplotlib alternative for 3D scatter plots

From Dev

Python/Matplotlib: 2d random walk with kde joint density contour in a 3d plot

From Dev

Python/Matplotlib: 2d random walk with kde joint density contour in a 3d plot

From Dev

How to determine the projection (2D or 3D) of a matplotlib axes object?

From Dev

How to generate data for matplotlib filled contour plots given the real coordinates?

From Dev

Control angle of image projection in 3D matplotlib graphs

From Dev

pylab 3d scatter plots with 2d projections of plotted data

From Dev

Python Plotly: X,Y Grid Contour Projection onto 3D Surface

From Dev

Plotting contour and wireframe plots with Matplotlib

From Dev

How to use mouse to rotate matplotlib 3D plots in wxPython?

From Dev

Matplotlib doesn't rotate 3D plots

From Dev

Matplotlib: 3D Scatter plots not recognizing labels

From Dev

How to use mouse to rotate matplotlib 3D plots in wxPython?

From Dev

why is matplotlib plotting the transpose of a matrix in 3D plots?

From Dev

3D data contour ploting using a kde

From Dev

Matlab 2d contour plot in 3d

From Dev

Adding extra contour lines using matplotlib 2D contour plotting

From Dev

Numpy fastest 3D to 2D projection

From Dev

Numpy fastest 3D to 2D projection

From Dev

matplotlib: imshow a 2d array with plots of its marginal densities

From Dev

Plotting Interpolated 3D Data As A 2D Image using Matplotlib

From Dev

Gnuplot - Plot data points on 2D contour plot

From Dev

Gnuplot - Plot data points on 2D contour plot

From Dev

Stop 3D plots from appearing 2D

From Dev

Superimposing 2D plots in 3D

Related Related

  1. 1

    3D histograms and Contour plots Python

  2. 2

    Python 2D plots as 3D (Matplotlib)

  3. 3

    plot multiple 2d contour plots in one 3d figure [Matlab]

  4. 4

    matplotlib 3d surface plots not showing

  5. 5

    Matplotlib alternative for 3D scatter plots

  6. 6

    Python/Matplotlib: 2d random walk with kde joint density contour in a 3d plot

  7. 7

    Python/Matplotlib: 2d random walk with kde joint density contour in a 3d plot

  8. 8

    How to determine the projection (2D or 3D) of a matplotlib axes object?

  9. 9

    How to generate data for matplotlib filled contour plots given the real coordinates?

  10. 10

    Control angle of image projection in 3D matplotlib graphs

  11. 11

    pylab 3d scatter plots with 2d projections of plotted data

  12. 12

    Python Plotly: X,Y Grid Contour Projection onto 3D Surface

  13. 13

    Plotting contour and wireframe plots with Matplotlib

  14. 14

    How to use mouse to rotate matplotlib 3D plots in wxPython?

  15. 15

    Matplotlib doesn't rotate 3D plots

  16. 16

    Matplotlib: 3D Scatter plots not recognizing labels

  17. 17

    How to use mouse to rotate matplotlib 3D plots in wxPython?

  18. 18

    why is matplotlib plotting the transpose of a matrix in 3D plots?

  19. 19

    3D data contour ploting using a kde

  20. 20

    Matlab 2d contour plot in 3d

  21. 21

    Adding extra contour lines using matplotlib 2D contour plotting

  22. 22

    Numpy fastest 3D to 2D projection

  23. 23

    Numpy fastest 3D to 2D projection

  24. 24

    matplotlib: imshow a 2d array with plots of its marginal densities

  25. 25

    Plotting Interpolated 3D Data As A 2D Image using Matplotlib

  26. 26

    Gnuplot - Plot data points on 2D contour plot

  27. 27

    Gnuplot - Plot data points on 2D contour plot

  28. 28

    Stop 3D plots from appearing 2D

  29. 29

    Superimposing 2D plots in 3D

HotTag

Archive