In this Plotly tutorial, you will learn how to plot a line chart or line graph in Python. You can use px.line() function to plot a line chart.
Example 1
# Import Plotly Module
import plotly.express as px
# Import Dataset
dataset = px.data.gapminder().query("continent=='Oceania'")
# Line Plot
plot = px.line(dataset, x="year", y="gdpPercap", color='country', title='Plotly Line Chart')
# Show the Plot
plot.show()Output:

Example 2
# Import Plotly Module import plotly.express as px # Data data = [5, 10, 15, 20, 30, 45, 50, 55, 75, 90, 100] # Line Graph plot = px.line(data, title='Plotly Line Graph', height=400, width=600) # Show the Plot plot.show()
Output:



