#132 Basic connected scatterplot

 

 

 

 

 

Connected scatterplots are just a mix between scatterplots and linecharts. They are made with the plot function of matplotlib.

If you want to custom them, just check the scatter and line sections!

 

 

 

 

 


# libraries
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns

# data
df=pd.DataFrame({'x': range(1,10), 'y': np.random.randn(9)*80+range(1,10) })

# plot
plt.plot( 'x', 'y', data=df, linestyle='-', marker='o')
plt.show()
  • Sponsors

  • 2 comments

    • This example doesn’t run with python 3.6. I get errors:

      multiple_lines.py:10: RuntimeWarning: Second argument ‘y1’ is ambiguous: could be a color spec but is in data; using as data. Either rename the entry in data or use three arguments to plot.
      plt.plot( ‘x’, ‘y1′, data=df, marker=’o’, markerfacecolor=’blue’, markersize=12, color=’skyblue’, linewidth=4)
      multiple_lines.py:11: RuntimeWarning: Second argument ‘y2’ is ambiguous: could be a color spec but is in data; using as data. Either rename the entry in data or use three arguments to plot.
      plt.plot( ‘x’, ‘y2′, data=df, marker=”, color=’olive’, linewidth=2)
      multiple_lines.py:12: RuntimeWarning: Second argument ‘y3’ is ambiguous: could be a color spec but is in data; using as data. Either rename the entry in data or use three arguments to plot.
      plt.plot( ‘x’, ‘y3′, data=df, marker=”, color=’olive’, linewidth=2, linestyle=’dashed’, label=”toto”)

      Reply

    Leave a Reply

    Your email address will not be published.