How to add line and scatter plots

To generate a more complicated plot, generate a three-dimensional potential. This is called a Goldstone potential, which is an important energy potential in physics used to describe a lot of things, including the Higgs mechanism. We will look at the scatter plot of this Goldstone potential, as shown in the following snippet:

# Scatter plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x,y = np.meshgrid(np.arange(-10,10,0.5), np.arange(-10,10,0.5))
r = np.linalg.norm([x,y], axis=0)
goldstone = -160*np.power(r,2)+np.power(r,4)
ax.scatter(x,y,goldstone)
  1. Here, we see a nice scatter plot:
  1. Also, we can pass all of the same kind of arguments here that we could pass for a two-dimensional scatter plot. We can change the colors, as shown in the following snippet:
# Scatter plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x,y = np.meshgrid(np.arange(-10,10,0.5), np.arange(-10,10,0.5))
r = np.linalg.norm([x,y], axis=0)
goldstone = -160*np.power(r,2)+np.power(r,4)
ax.scatter(x,y,goldstone, c='r')

The output of this is as follows:

  1. We can also change the sizes of the standard scatter plot keyword arguments that we get with a 2D plot. We can do this in 3D as well, by adding s=1:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset