$ python3 -m pip install -U matplotlib
WARNING: The scripts f2py, f2py3 and f2py3.9 are installed in '/home/rene/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The scripts fonttools, pyftmerge, pyftsubset and ttx are installed in '/home/rene/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
import numpy as np import matplotlib.pyplot as plt x = np.linspace(-np.pi, np.pi, 300) y = np.sin(x) plt.plot(x , y, 'r-', label='sin(x)') # r- draws a red line plt.ylim(-1.25, 1.25) plt.legend() plt.show()
tkinter solved the problem. _add_data_doc() | |
_api | Module |
atexit | Module |
bezier | Module |
cbook | Module |
checkdep_usetex() | |
_check_versions() | |
_c_internal_utils | Module |
_cm | Module |
cm | Module |
_cm_listed | Module |
_color_data | Module |
colormaps | ? |
colors | Module |
color_sequences | ? |
contextlib | Module |
cycler() | |
defaultParams | dict object |
default_test_modules | list object |
_deprecated_ignore_map | dict object |
_deprecated_map | dict object |
_deprecated_remain_as_none | dict object |
_docstring | Module |
_ensure_handler | ? |
_enums | Module |
_ExecInfo | matplotlib._ExecInfo class |
ExecutableNotFoundError | matplotlib.ExecutableNotFoundError class |
_fontconfig_pattern | Module |
ft2font | Module |
functools | Module |
get_backend() | |
get_cachedir() | |
get_configdir() | |
_get_config_or_cache_dir() | |
get_data_path() | |
_get_executable_info | ? |
_get_ssl_context | ? |
_get_version() | |
_get_xdg_cache_dir() | |
_get_xdg_config_dir() | |
importlib | Module |
_init_tests() | |
inspect | Module |
interactive() | |
is_interactive() | |
is_url() | |
_label_from_arg() | |
locale | Module |
_log | ? |
_logged_cached() | |
logging | Module |
MatplotlibDeprecationWarning | matplotlib._api.deprecation.MatplotlibDeprecationWarning class |
matplotlib_fname() | |
MutableMapping | ? |
namedtuple() | |
numpy | Module |
_open_file_or_url() | |
os | Module |
Parameter | inspect.Parameter class |
_parse_to_version_info() | |
parse_version() | |
Path | pathlib.Path class |
_path | Module |
path | Module |
pprint | Module |
_preprocess_data() | |
rc() | A convenience function that allows to set multiple runtime configurations (=rc) at once. See also rcParams. |
rc_context() | A context manager to override values of rcParams temporaily (with mpl.rc_context({'lines.linewidth': 4}): …). rc_context can also be used as a decorator to set rc defaults for a given function. |
rcdefaults() | |
rc_file() | |
rc_file_defaults() | |
RcParams | ? |
rcParams | An instance of matplotlib.RcParams which is a dictionary like object used for run-time (=rc) configuration (for example mpl.rcParams['lines.lineWidth'] = 3). See also rc() and rc_context and the list of rcParams. |
rc_params() | |
rcParamsDefault | ? |
rc_params_from_file() | |
_rc_params_in_file() | |
rcParamsOrig | ? |
rcsetup | Module |
re | Module |
_replacer() | |
sanitize_sequence() | |
scale | Module |
set_loglevel() | |
shutil | Module |
subprocess | Module |
sys | Module |
tempfile | Module |
test() | |
ticker | Module |
transforms | Module |
use() | Configure the backend. |
validate_backend() | |
_version | Module |
_VersionInfo | matplotlib._VersionInfo class |
warnings | Module |
When using Matplotlib in a web server it is strongly recommended to not use pyplot (pyplot maintains references to the opened figures to make `~.matplotlib.pyplot.show` work, but this will cause memory leaks unless the figures are properly closed). Since Matplotlib 3.1, one can directly create figures using the `.Figure` constructor and save them to in-memory buffers. In older versions, it was necessary to explicitly instantiate an Agg canvas (see e.g. :doc:`/gallery/user_interfaces/canvasagg`).
matplotlib.pyplot is a collection of functions that make matplotlib work like MATLAB. numpy.array or numpy.ma.masked_array objects, or objects that can be passed to numpy.asarray(). matplotlib.figure.Figure object
matplotlib.axes.Axes object represents a plot
matplotlib.axis.Axis object represents one of the plot's axis (x, y or z) Axes class is central to matplotlib because it defines the plotting area for data to be drawn. import matplotlib.pyplot as plt import numpy as np # # Create a figure … # fig = plt.figure() # # … use the figure to create one or more axes … # ax = fig.add_subplot(2, 1, 1) # two rows, one column, first plot # # … and use the axes to create the Artist primitives. # ax.…() fig.show() plt.waitforbuttonpress() # Really necessary?
fig, ax = plt.subplots()
%matplotlib