Generators with plots

0 votes
Can I use generators to plot graphs?
Jul 16 in Python by Fata
• 1,000 points
16 views

1 answer to this question.

0 votes
Yes, you can. I tried doing it initially with Matplotlib but that didn't really help. Then I

 tried using seaborn and found that seaborn actually supports plotting using generators. Try the following piece of code and make sure to run this twice.

EXAMPLE:

import numpy as np
from matplotlib import pyplot as plt
import seaborn as sb
def s(flip = 2):
    x = np.linspace(0, 14, 100)
    for i in range(1, 10):
        yield(plt.plot(x, np.sin(x + i * .5) * (7 - i) * flip))

sb.set()
s=s()
plt.show()

print(next(s))
answered Jul 16 by Wajiha
• 1,840 points

Related Questions In Python

+2 votes
2 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

answered Aug 13, 2018 in Python by bug_seeker
• 15,350 points
4,785 views
0 votes
1 answer

Need help writing a dataframe into a csv with the help of a loop

Using the following logic you can arrive ...READ MORE

answered Apr 17, 2018 in Python by anonymous
876 views
0 votes
1 answer

Need help with searching a binary search tree

Instead of multiplying the number of nodes ...READ MORE

answered Apr 17, 2018 in Python by anonymous
26 views
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 56,520 points
116 views
0 votes
1 answer

How to perform web scraping with python?

Hey, there are various libraries used in ...READ MORE

answered Apr 20, 2018 in Python by aayushi
• 750 points
233 views
+1 vote
2 answers

Measuring the distance between pixels on OpenCv with Python

You can try this: Mat pts1(nPts, 1, CV_8UC2), ...READ MORE

answered Aug 24, 2018 in Python by Omkar
• 67,290 points
2,544 views
0 votes
1 answer

OSX 10.11 with py2app?

I'm not sure if this is your ...READ MORE

answered May 9, 2018 in Python by charlie_brown
• 7,710 points
163 views
0 votes
1 answer

Difference between function and generator?

Normal Functions vs Generator Functions: Generators in Python ...READ MORE

answered Jul 15 in Python by Wajiha
• 1,840 points
30 views
0 votes
1 answer

Generator Expressions vs. List Comprehension

Generator expression resemble list comprehensions. List comprehensions ...READ MORE

answered Jul 15 in Python by Wajiha
• 1,840 points
19 views
0 votes
0 answers

Produce infinite number stream?

Is it possible to produce an infinite ...READ MORE

Jul 16 by Fata
• 1,000 points
8 views