For the second, we can use a slice of the original dataframe. x-ticks: 10 equally spaced tick labels.įor the first, we can use the np.arange() function.This means that we’ll need to generate two objects to pass to matplotlib: Practically in our case, I believe it would be interesting to show 10 dates along the x-axis. x-ticks-labels: The label you want to put at the tick.x-ticks: The place in the dataset where you want a label to be applied. ![]() When it comes to the x-axis in matplotlib, there’s two important pieces to that axis: This returns a plot that looks like this: The original graph without x-axis labels.Īs you can see, the x-asis is empty. t_title("COVID-19 cases in Bay Area Counties") 'Santa Clara'] plot = cases_ot(figsize=(20,10)) In my case, I’m interested in 4 counties, so we’ll filter by those four counties: counties = ['Alameda', Now that we have a cases dataset, we can plot that dataset. ![]() Import pandas as pd cases = pd.read_csv('')Ĭases_clean = cases = "California"].set_index("Admin2").T.drop() If you want more information about these intro steps, please refer to my previous post. Let’s start with the data we’ll use for this graph. In this (very quick) blog post I’ll show you how to add an x-axis to a matplotlib plot. ![]() One thing that I didn’t like about my graphs was that they didn’t contain an x-axis, which made them a little bit harder to read. I’ve blogged before about how I’m doing some of my own data analysis on the COVID-19 numbers.
0 Comments
Leave a Reply. |