Generators with plots

0 votes
Can I use generators to plot graphs?
Jul 16, 2019 in Python by Fata
• 1,050 points
75 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,950 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,400 points
21,337 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
1,897 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
72 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
• 57,550 points
285 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
642 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,020 points
6,109 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,950 points
1,144 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,950 points
171 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
38 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 in Python by MD
• 43,500 points
74 views