Plotting a log-log graph from Excel file

262 views Asked by At

I tried to plot a graph by importing an Excel file to plot a log-log graph.

This was my code but it seems I'm not getting it right.

import matplotlib.pyplot as plt

import pandas as pd

df=pd.read_excel("C:\\users\mycomputer\\myfile.xlsx")

df.plot(x, y)

plt.show()
1

There are 1 answers

0
jsmart On

Here is a short example:

# from first cell in Jupyter notebook
import matplotlib.pyplot as plt
import pandas as pd

s = pd.Series(data=[1, 10, 100, 1_000, 10_000], 
              index=[1, 2, 3, 4, 5])

# from second cell in Jupyter notebook
fig, ax = plt.subplots(figsize=(8, 5))
ax.plot(s)
ax.set(xscale='log', yscale='log', 
       xlabel='x-axis', ylabel='y-axis', title='Plot Title Here')
plt.show();

Here is a good reference on Matplotlib: https://jakevdp.github.io/PythonDataScienceHandbook/04.00-introduction-to-matplotlib.html