Home > other >  How can I make a scatter plot using proplot? (Python)
How can I make a scatter plot using proplot? (Python)

Time:06-07

I just downloaded the ProPlot package and am wondering how I can make a scatter plot. I looked into this example, but as I tried

import proplot as plt
plt.figure(...)
plt.scatter(...)

it returns me AttributeError: module 'proplot' has no attribute 'scatter' . My plot worked when I did

import proplot as plt
import matplotlib.pyplot as plt
plt.figure(...)
plt.scatter(...)

And I did see the effect of proplot in this way. However, I don't think it's right to import two packages with the same notation plt. Is there a better way I can generate the scatter plot using proplot? Thanks!

CodePudding user response:

Proplot does not offer a direct replacement for the scatter plot at the top level of the proplot module. The only way to construct it is to call the method of an axis object:

import proplot as pplt
fig, ax = pplt.subplots()
ax.scatter()

Or alternatively:

fig = pplt.figure()
ax = fig.subplot()
ax.scatter(...)

Note that if you import matplotlib after proplot under the same name plt alias, you won't be able to use the proplot interface under plt since it'll be replaced by matplotlib. It is not "wrong" to do so, since it is legal python, but surely not what you intended to accomplish.

  • Related