Skip to main content

__ Back to top

__ ` Ctrl ` \+ ` K `

[ ![pandas 2.2.1 documentation - Home](../_static/pandas.svg) ](../index.html)

Site Navigation

  * [ Getting started ](../getting_started/index.html)
  * [ User Guide ](index.html)
  * [ API reference ](../reference/index.html)
  * [ Development ](../development/index.html)
  * [ Release notes ](../whatsnew/index.html)

  * [ __ GitHub  ](https://github.com/pandas-dev/pandas "GitHub")
  * [ __ Twitter  ](https://twitter.com/pandas_dev "Twitter")
  * [ __ Mastodon  ](https://fosstodon.org/@pandas_dev "Mastodon")

Site Navigation

  * [ Getting started ](../getting_started/index.html)
  * [ User Guide ](index.html)
  * [ API reference ](../reference/index.html)
  * [ Development ](../development/index.html)
  * [ Release notes ](../whatsnew/index.html)

  * [ __ GitHub  ](https://github.com/pandas-dev/pandas "GitHub")
  * [ __ Twitter  ](https://twitter.com/pandas_dev "Twitter")
  * [ __ Mastodon  ](https://fosstodon.org/@pandas_dev "Mastodon")

  * [ 10 minutes to pandas ](10min.html)
  * [ Intro to data structures ](dsintro.html)
  * [ Essential basic functionality ](basics.html)
  * [ IO tools (text, CSV, HDF5, â¦) ](io.html)
  * [ PyArrow Functionality ](pyarrow.html)
  * [ Indexing and selecting data ](indexing.html)
  * [ MultiIndex / advanced indexing ](advanced.html)
  * [ Copy-on-Write (CoW) ](copy_on_write.html)
  * [ Merge, join, concatenate and compare ](merging.html)
  * [ Reshaping and pivot tables ](reshaping.html)
  * [ Working with text data ](text.html)
  * [ Working with missing data ](missing_data.html)
  * [ Duplicate Labels ](duplicates.html)
  * [ Categorical data ](categorical.html)
  * [ Nullable integer data type ](integer_na.html)
  * [ Nullable Boolean data type ](boolean.html)
  * Chart visualization 
  * [ Table Visualization ](style.html)
  * [ Group by: split-apply-combine ](groupby.html)
  * [ Windowing operations ](window.html)
  * [ Time series / date functionality ](timeseries.html)
  * [ Time deltas ](timedeltas.html)
  * [ Options and settings ](options.html)
  * [ Enhancing performance ](enhancingperf.html)
  * [ Scaling to large datasets ](scale.html)
  * [ Sparse data structures ](sparse.html)
  * [ Frequently Asked Questions (FAQ) ](gotchas.html)
  * [ Cookbook ](cookbook.html)

  * [ __ ](../index.html)
  * [ User Guide ](index.html)
  * Chart visualization 

#  Chart visualization  #

Note

The examples below assume that youâre using [ Jupyter
](https://jupyter.org/) .

This section demonstrates visualization through charting. For information on
visualization of tabular data please see the section on [ Table Visualization
](style.html) .

We use the standard convention for referencing the matplotlib API:

    
    
    In [1]: import matplotlib.pyplot as plt
    
    In [2]: plt.close("all")
    

We provide the basics in pandas to easily create decent looking plots. See [
the ecosystem page ](https://pandas.pydata.org/community/ecosystem.html) for
visualization libraries that go beyond the basics documented here.

Note

All calls to ` np.random  ` are seeded with 123456.

##  Basic plotting: ` plot  ` #

We will demonstrate the basics, see the [ cookbook  ](cookbook.html#cookbook-
plotting) for some advanced strategies.

The ` plot  ` method on Series and DataFrame is just a simple wrapper around [
` plt.plot()  `
](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.plot.html#matplotlib.axes.Axes.plot
"\(in Matplotlib v3.8.3\)") :

    
    
    In [3]: np.random.seed(123456)
    
    In [4]: ts = pd.Series(np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000))
    
    In [5]: ts = ts.cumsum()
    
    In [6]: ts.plot();
    

![../_images/series_plot_basic.png](../_images/series_plot_basic.png)

If the index consists of dates, it calls [ ` gcf().autofmt_xdate()  `
](https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.autofmt_xdate
"\(in Matplotlib v3.8.3\)") to try to f