Generators with plots

0 votes
Can I use generators to plot graphs?
Jul 16, 2019 in Python by Fata
• 1,050 points
993 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, 2019 by Wajiha
• 1,960 points

Related Questions In Python

+2 votes
4 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,520 points
122,239 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
3,369 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
851 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
• 58,020 points
1,554 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
1,788 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
• 69,220 points
10,536 views
0 votes
1 answer

Difference between function and generator?

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

answered Jul 15, 2019 in Python by Wajiha
• 1,960 points
4,887 views
0 votes
1 answer

Generator Expressions vs. List Comprehension

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

answered Jul 15, 2019 in Python by Wajiha
• 1,960 points
1,061 views
0 votes
0 answers

Produce infinite number stream?

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

Jul 16, 2019 by Fata
• 1,050 points
104 views
0 votes
1 answer

How to convert one list into generator?

Hi@akhtar, Say, you have one list A. Now convert ...READ MORE

answered Apr 23, 2020 in Python by MD
• 95,460 points
2,516 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP