'Matplotlib Issues in venv
I have encountered an issue I've never really had before. I am pretty familiar with matplotlib and making figure objects, axes and all that. However, when I try to run this EXTREMELY simple code in matplotlib...
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0,21)
y = x
plt.plot(x,y)
plt.show()
I get the following error...
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [7], in <module>
1 plt.plot(x,y)
----> 2 plt.show()
AttributeError: 'AxesSubplot' object has no attribute 'show'
I cannot understand why I am getting this attribute error. I do not think this is a code issue, as this is the simplest possible matplotlib code that we could write (this should return a line of slope 1 in a range of 1 to 20, basically the 'hello world' of matplotlib). Does anyone have insight into why I'm getting this error?
I suspect that this is a package issue. This is my first time using matplotlib in a python venv, as opposed to a conda virtual environment. When I pip install matplotlib, I feel like I may be missing a package that supports the .show() method. I never had an issue using matplotlib on the conda environment because I installed it through the anaconda navigator. I trust that the pip install would take care of any package dependencies, but I'm not sure. If anyone has insight it would be much appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
