Gowthaman
Gowthaman

Reputation: 59

How to see the graph plotted using DataFrame in PyCharm Community Edition?

I started Python programming today...

I have a simple code that created a Pandas DataFrame from a Input JSON file. I also plotted a graph. But I don't know how to toggle the output screen visualizing this graph in PyCharm community edition?

The code compiles successfully however with the following warning: "UserWarning: Attempting to set identical left == right == 1.0 results in singular transformations; automatically expanding."

Now how do I view/toggle/export this graph?

# Python program showing
# use of json package

import pandas as pd
import json

with open("test.json", "r") as read_it:
    data = json.load(read_it)

df = pd.DataFrame(data, index=[0])

print(df)
df.plot(x='Rpm', y='Torque')

I want to see the actual x y plot itself....

Upvotes: 1

Views: 1123

Answers (1)

Sheldore
Sheldore

Reputation: 39072

You can save the figure using plt.savefig from matplotlib

import pandas as pd
import json
import matplotlib.pyplot as plt # <--- Import pyplot 

with open("test.json", "r") as read_it:
    data = json.load(read_it)

df = pd.DataFrame(data, index=[0])

print(df)
df.plot(x='Rpm', y='Torque')
plt.savefig('figure.png') # <--- Name the file whatever you want

If you want to just visualize it, and not save it, you can use

plt.show()

Upvotes: 1

Related Questions