Skip to content
← Back to Community
Visualizing plots
Profile icon
ktiwari9

How would you use matplotlib to show the outputs? I tried running the code with a simple plotting routine but there was no output since it shows the console window only. Am I missing something?

Voters
Profile icon
SulhiAqilah
Profile icon
ktiwari9
Comments
hotnewtop
Profile icon
timmy_i_chen

In Repl.it, you need to use savefig - here's a really simple example: https://repl.it/@timmy_i_chen/docs-matplotlib-example

Profile icon
J21blackcat

plt.show() may work for you.

Profile icon
ktiwari9

@J21blackcat :
This is my code:

# import all necessary modules here import numpy as np import math import matplotlib.pyplot as plt # Variables for generating inputs and targets numSamples = 8 # number of sample points numDim = 1 # input dimensions # Generate Inputs and Targets here X = np.linspace(start=0, stop=2*math.pi, num=numSamples).reshape((numSamples,numDim)) ## Inputs Y_true = np.sin(X) # Targets plt.plot(X,Y_true) plt.xlabel("Inputs") plt.ylabel("Targets") plt.title("Ground Truth") plt.show()

Already have everything in place. Still dont get the plots when I run the code using Ctrl + Enter.

Profile icon
J21blackcat

@ktiwari9

I have no problem with your code and got the following graph.
If you use Anaconda, maybe using "pythonw" instead of "python" may help you.

This file cannot be displayed: https://storage.googleapis.com/replit/images/1531988385901_dcbbc6e9c652e190950c597745891349.pn

Or, you can see my code using Matplotlib. As timmy_i_chen mentioned, in Repl, we cannot show the graph, but can save the graph using "plt.savefig("name_of_your_data.png")".

https://repl.it/@J21blackcat/Rock-paper-scissors-simulator