Python Forum
Three-dimensional Contour Plots
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Three-dimensional Contour Plots
#1
Hi. I am beginner in Python programming. I want to do a Three-dimensional Contour Plots, like this: https://jakevdp.github.io/PythonDataScie...tting.html . Why the code is not working? I know that "figure" is not declared in main...how can I do this? which are other mistakes in code? Can anyone write the full correct code?
from matplotlib.pyplot import axis
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = plt.axes(projection='3d')
def f(x,y):
    return np.sin(np.sqrt(x ** 2 + y ** 2))

x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)

X, Y = np.meshgrid(x, y)
Z = f(X, Y)

fig = plt.figure()
ax = plt.axes(projection='3d')
ax.contour3D(X, Y, Z, 50, cmap='binary')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z');
ax.view_init(60, 35)
fig
Reply
#2
here's a tutorial you may want to look at: https://matplotlib.org/mpl_toolkits/mplo...orial.html

or this one: https://matplotlib.org/examples/mplot3d/..._demo.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Plots issue shane1236 1 2,049 Aug-06-2019, 10:00 AM
Last Post: shane1236
  Add space between plots AdWill97 0 2,033 May-15-2019, 02:04 PM
Last Post: AdWill97
  How to add an element such as an average to a multi-dimensional array? xhughesey 6 3,917 Jan-06-2019, 10:47 PM
Last Post: xhughesey
  2D to 3D plots ekq378 0 9,319 Nov-14-2018, 06:13 PM
Last Post: ekq378
  2 Dimensional NumPy for beginners Jack_Sparrow 2 3,066 May-08-2018, 05:21 PM
Last Post: killerrex
  Reproduce Minitab contour plot with Python BennyS 4 3,755 Apr-16-2018, 11:45 AM
Last Post: BennyS
  Recurse through n-dimensional array ColdDeath 2 2,925 Apr-05-2018, 11:20 AM
Last Post: KenniT
  Two Dimensional Chart from CSV File srini1995 0 2,204 Nov-27-2017, 07:10 AM
Last Post: srini1995
  How to sum elements of same position in n dimensional array Felipe 2 4,074 May-11-2017, 10:33 AM
Last Post: Felipe

Forum Jump:

User Panel Messages

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