Show Sidebar Hide Sidebar

Plot CSV Data in Python

How to create charts from csv files with Plotly and Python

CSV or comma-delimited-values is a very popular format for storing structured data. In this tutorial, we will see how to plot beautiful graphs using csv data, and Pandas. We will learn how to import csv data from an external source (a url), and plot it using Plotly and pandas.

First we import the data and look at it.

In [1]:
import pandas as pd
df = pd.read_csv('')
0 2014-01-02 77.445395
1 2014-01-03 77.045575
2 2014-01-06 74.896972
3 2014-01-07 75.856461
4 2014-01-08 75.091947

Plot from CSV with Plotly Express

In [2]:
import pandas as pd
import as px

df = pd.read_csv('')

fig = px.line(df, x = 'AAPL_x', y = 'AAPL_y', title='Apple Share Prices over time (2014)')

Plot from CSV with graph_objects

In [3]:
import pandas as pd
import plotly.graph_objects as go

df = pd.read_csv('')

fig = go.Figure(go.Scatter(x = df['AAPL_x'], y = df['AAPL_y'],
                  name='Share Prices (in USD)'))

fig.update_layout(title='Apple Share Prices over time (2014)',
                   plot_bgcolor='rgb(230, 230,230)',


See for more information about Plotly's Python API!