How can I change the x and y-axis labels in plotly because in matplotlib, I can simply use plt.xlabel but I am unable to do that in plotly.
By using this code in a dataframe:
Date = df[df.Country=="India"].Date
New_cases = df[df.Country=="India"]['7day_rolling_avg']
px.line(df,x=Date, y=New_cases, title="India Daily New Covid Cases")
I get this output:
In this X and Y axis are labeled as X and Y how can I change the name of X and Y axis to "Date" and "Cases"
update_layout(
xaxis_title="Date", yaxis_title="7 day avg"
)
import pandas as pd
import io, requests
df = pd.read_csv(
io.StringIO(
requests.get(
"https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/vaccinations/vaccinations.csv"
).text
)
)
df["Date"] = pd.to_datetime(df["date"])
df["Country"] = df["location"]
df["7day_rolling_avg"] = df["daily_people_vaccinated_per_hundred"]
Date = df[df.Country == "India"].Date
New_cases = df[df.Country == "India"]["7day_rolling_avg"]
px.line(df, x=Date, y=New_cases, title="India Daily New Covid Cases").update_layout(
xaxis_title="Date", yaxis_title="7 day avg"
)