Apr-23-2022, 04:41 PM
Hi all,
New forum user here.
When I run this code from the Matplotlib examples, I get the following error:
New forum user here.
When I run this code from the Matplotlib examples, I get the following error:
Error:Traceback (most recent call last):
File /opt/intel/oneapi/intelpython/latest/envs/2022.0.2/lib/python3.9/site-packages/matplotlib/style/core.py:111 in use
rc = rc_params_from_file(style, use_default_template=False)
File /opt/intel/oneapi/intelpython/latest/envs/2022.0.2/lib/python3.9/site-packages/matplotlib/__init__.py:985 in rc_params_from_file
config_from_file = _rc_params_in_file(fname, fail_on_error)
File /opt/intel/oneapi/intelpython/latest/envs/2022.0.2/lib/python3.9/site-packages/matplotlib/__init__.py:916 in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File /opt/intel/oneapi/intelpython/latest/envs/2022.0.2/lib/python3.9/contextlib.py:119 in __enter__
return next(self.gen)
File /opt/intel/oneapi/intelpython/latest/envs/2022.0.2/lib/python3.9/site-packages/matplotlib/__init__.py:902 in _open_file_or_url
with open(fname, encoding=encoding) as f:
FileNotFoundError: [Errno 2] No such file or directory: '_mpl-gallery-nogrid'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ~/Documents/Python/matplotlib_example1.py:4 in <module>
plt.style.use('_mpl-gallery-nogrid')
File /opt/intel/oneapi/intelpython/latest/envs/2022.0.2/lib/python3.9/site-packages/matplotlib/style/core.py:114 in use
raise IOError(
OSError: '_mpl-gallery-nogrid' not found in the style library and input is not a valid URL or path; see `style.available` for list of available styles
My Code:import matplotlib.pyplot as plt import numpy as np plt.style.use('_mpl-gallery-nogrid') # make a stream function: X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) # make U and V out of the streamfunction: V = np.diff(Z[1:, :], axis=1) U = -np.diff(Z[:, 1:], axis=0) # plot: fig, ax = plt.subplots() ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V) plt.show()