Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize 3D Chart in Matplotlib

Shulou Source: shulou.com Published: 2022-06-01 18:37:26 09月16日 Update

This article is about how to implement 3D diagrams in Matplotlib. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Background introduction

Demonstrates drawing a 3D map of a surface defined in polar coordinates. And use the built-in color map in matplotlib to show.

Getting started example code block''= 3D surfaces and polar coordinates = = demonstrates drawing surfaces defined in polar coordinates. Use YlGnBu color map to reverse the version.''# Import Axes3D Registration 3D projection from mpl_toolkits.mplot3d import Axes3Dimport matplotlib.pyplot as pltimport numpy as np# definition subchart Add 3D projection fig = plt.figure () ax = fig.add_subplot (111111projection='3d') # create the grid in polar coordinates and calculate the corresponding Z value. R = np.linspace (0,1.25,50) p = np.linspace (0, 2*np.pi, 50) R, P = np.meshgrid (r, p) Z = ((Renewal 2-1) * * 2) # represents the grid X, Y = R*np.cos (P) in the Cartesian system R*np.sin (P) # draw the surface .ax.plot _ surface (X, Y, Z,\ cmap=plt.cm.YlGnBu_r) # adjust the limit and add the numeric label ax.set_zlim (0 1) ax.set_xlabel (ringing $\ phi_\ mathrm {real} $') ax.set_ylabel (rattling $\ phi_\ mathrm {im} $') ax.set_zlabel (ringing phi V (\ phi) $') # form display plt.show () Thank you for reading! This is the end of the article on "how to realize 3D Chart in Matplotlib". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Polar coordinates charts content surfaces more articles grids surfaces projections presentations good practical middle tables synonyms code examples numbers articles tags versions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Redmi NVidia macOS