T
T
Timebird2016-06-05 11:32:01
Python
Timebird, 2016-06-05 11:32:01

How to plot a given number of points on a function plot in PyPlot?

The number of points when plotting the graph of the function was set somehow like this:
t = linspace(0, 0.8, 251)
Is it possible to set in some alternative way the number of points to the function when I build, for example, the dependence of one array on another:
plt.plot(array1, array2, '-g', label='label1')? With pyplot?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-06-06
@Timebird

What does it mean to set the number of points?
pyplot doesn't know what function you're looking at, so it won't be able to plot you for certain points.
To display only those points that you need, you need to use slices.
For example:

import matplotlib.pyplot as plt
import numpy as np


t = np.linspace(0, np.pi, 314)
y = np.sin(t)

plt.figure(1)
plt.plot(t, y, '-g')
plt.plot(t[100:150:5], y[100:150:5], 'og')
plt.plot(t[::10], y[::10], '*r')
plt.show()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question