How can one creat a simple, 2 dimensional plot of a basic inequality. The result is a numbered line with one or two lines overlaid. The line or lines would begin or end with an arrow, a filled-in circle, or an open circle.
Using matplotlib, is there a way to create simple 2d plots of basic inequalities
241 views Asked by sophware AtThere are 2 answers
Yes, there is. Add matplotlib to your python distribution and then import it in your code. I usually use the following when importing it. import matplotlib.pyplot as plt. Then I can use the following line also in my python code:
plt.plot(x, y)` This will give you a simple x,y plot of the values you have defined.
In the line import matplotlib.pyplot as plt, I'm loading maplotlib as plt. This allows you to refer to it as plt. The x-axis can be defined by the user as a set of values or you can generate the x-values by using something like x = np.linspace(0, 20, 200)
where linspace is a function to generate equally spaced points. The 0 and 20 refer to the xmin and xmax values while 200 is the number of x-values generated.
you can also simply do
x = (1,3,5,9,11,13)
y = (1,9,25,81,121,169)
and plt.plot(x,y)
Some techniques that you can use:
zorder
s so that the lines are on top of the xaxisplt.subplots(nrows=...)
, setting thefigsize
accordinglyHere is some code to get you started.