Graph Axis Markings not showing

here is my code:

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from pandas.plotting import register_matplotlib_converters

# Import data (Make sure to parse dates. Consider setting index column to 'date'.)
df = pd.read_csv("/content/drive/MyDrive/google-colab-data/fcc-forum-pageviews.csv")

# Clean data
df = df[(df['value'] <= df['value'].quantile(.975)) & (df['value'] >= df['value'].quantile(.025))]

def draw_line_plot():
    # Draw line plot
    plt.plot(df["date"], df["value"])
    plt.title("Daily freeCodeCamp Forum Page Views 5/2016-12/2019")
    plt.ylabel("Page Views")
    fig = plt

    # Save image and return fig (don't change this part)
    return fig

and when I run this code, the graph show up fine, but the axis markings don’t show

here is my output:

You can define the axis and margins in matplotlib, there are different forms, you could use axis.margins() or matplotlib.pyplot.margins
For example.
you can see more examples here:

Hope this helps.

The problem is there is a black bar over my labels, so I am not sure if these functions will help?

It is not a black bar but actual df['value'] from your dataframe. It looks like a black bar because of the quantity of values involved (you are working with time series after all) all of these values are written one over the other as x-tick labels.
That is the reason why I recommended ticks, ticks are included in the documentation recommended above:
for example:
ticks = plt.xticks(pos[::15], df['value'].values[::15], rotation=90)

If you still do not believe me, you can check by yourself in the documentation, or in:

Hope this helps

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.