How to plot multiple functions on the same figure, in Matplotlib?

user3277335

How can I plot the following 3 functions (i.e. sin, cos and the addition), on the domain t, in the same figure?

from numpy import *
import math
import matplotlib.pyplot as plt

t = linspace(0, 2*math.pi, 400)

a = sin(t)
b = cos(t)
c = a + b
Srivatsan

To plot multiple graphs on the same figure you will have to do:

from numpy import *
import math
import matplotlib.pyplot as plt

t = linspace(0, 2*math.pi, 400)
a = sin(t)
b = cos(t)
c = a + b

plt.plot(t, a, 'r') # plotting t, a separately 
plt.plot(t, b, 'b') # plotting t, b separately 
plt.plot(t, c, 'g') # plotting t, c separately 
plt.show()

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I plot multiple figure in the same line with matplotlib?

From Dev

matplotlib.pyplot.plotfile() - How to plot multiple graphs into same figure?

From Dev

Plot multiple functions with the same properties in matplotlib

From Dev

Multiple plot in the same figure

From Dev

How do I plot multiple functions in matplotlib?

From Dev

How to plot 2 subplots from different functions in the same window(figure)?

From Dev

Multiple plots on same figure with DataFrame.Plot

From Dev

Multiple plots on same figure with DataFrame.Plot

From Dev

How to plot multiple swarmplots in a single figure?

From Dev

How to plot on the same figure with different data and delete the old plot(s)

From Dev

Plot on the same figure in Matlab

From Dev

Matplotlib - Plot multiple lines on the same chart

From Dev

Plotting to 1 figure using multiple functions with Matplotlib, Python

From Dev

Plot figure problems with python and matplotlib

From Dev

How to plot two plots in the same figure in plotly.js

From Dev

How can I multiple plot in one figure at Matlab?

From Dev

How to plot one figure with multiple lines in python using

From Dev

In matlab, plot a heatmap and a line plot on the same figure

From Dev

In matlab, plot a heatmap and a line plot on the same figure

From Dev

Combining mayavi and matplotlib in the same figure

From Dev

Combining mayavi and matplotlib in the same figure

From Dev

multiple plot in one figure in Python

From Dev

Python Plot- Multiple the data in plot figure

From Dev

matplotlib: multiple plots on one figure

From Dev

How to display side by side bar plot as well as stacked bar plot in the same figure in R?

From Dev

matplotlib figure without whitespace around plot

From Dev

Matplotlib: using a figure object to initialize a plot

From Dev

Plot a matplotlib figure within a for loop at each step

From Dev

Matplotlib figure/plot/canvas/layout hides buttons

Related Related

  1. 1

    How can I plot multiple figure in the same line with matplotlib?

  2. 2

    matplotlib.pyplot.plotfile() - How to plot multiple graphs into same figure?

  3. 3

    Plot multiple functions with the same properties in matplotlib

  4. 4

    Multiple plot in the same figure

  5. 5

    How do I plot multiple functions in matplotlib?

  6. 6

    How to plot 2 subplots from different functions in the same window(figure)?

  7. 7

    Multiple plots on same figure with DataFrame.Plot

  8. 8

    Multiple plots on same figure with DataFrame.Plot

  9. 9

    How to plot multiple swarmplots in a single figure?

  10. 10

    How to plot on the same figure with different data and delete the old plot(s)

  11. 11

    Plot on the same figure in Matlab

  12. 12

    Matplotlib - Plot multiple lines on the same chart

  13. 13

    Plotting to 1 figure using multiple functions with Matplotlib, Python

  14. 14

    Plot figure problems with python and matplotlib

  15. 15

    How to plot two plots in the same figure in plotly.js

  16. 16

    How can I multiple plot in one figure at Matlab?

  17. 17

    How to plot one figure with multiple lines in python using

  18. 18

    In matlab, plot a heatmap and a line plot on the same figure

  19. 19

    In matlab, plot a heatmap and a line plot on the same figure

  20. 20

    Combining mayavi and matplotlib in the same figure

  21. 21

    Combining mayavi and matplotlib in the same figure

  22. 22

    multiple plot in one figure in Python

  23. 23

    Python Plot- Multiple the data in plot figure

  24. 24

    matplotlib: multiple plots on one figure

  25. 25

    How to display side by side bar plot as well as stacked bar plot in the same figure in R?

  26. 26

    matplotlib figure without whitespace around plot

  27. 27

    Matplotlib: using a figure object to initialize a plot

  28. 28

    Plot a matplotlib figure within a for loop at each step

  29. 29

    Matplotlib figure/plot/canvas/layout hides buttons

HotTag

Archive