How can I fix my python code to draw the graph?


Joseph Tannuri

My code exits with code 0, so my code has no errors, but it's still running without drawing the flow on the cylinder I want, can anyone help me with this?

    import sympy as s
    import matplotlib.pyplot as plt
    import numpy as np

    from sympy.abc import x,y


    def cylinder_stream_fct(U=1,R=1):
        r=s.sqrt(x**2+y**2)
        theta=s.atan2(y,x)
        return U*(r-R**2/r)*s.sin(theta)
    def velocity_field(psi):
        u=s.lambdify((x,y), psi.diff(y), 'numpy')
        v=s.lambdify((x,y), -psi.diff(x), 'numpy')
        return u,v
    def plot_streamlines(ax, u, v,xlim=(-1,1), ylim=(-1,1)):
        x0, x1=xlim
        y0, y1=ylim
        Y,X= np.ogrid[y0:y1:100j,x0:x1:100j]
        ax.streamplot(X,Y,u(X,Y),v(X,Y),color='red')
    def format_axes(ax):
        ax.set_aspect('equal')
        ax.figure.subplots_adjust(bottom=0, top=1, left=0, right=1)
        ax.xaxis.set_ticks([])
        ax.yaxis.set_ticks([])
        for spine in ax.spines.values():
            spine.set_visible(False)
    psi=cylinder_stream_fct()
    u,v=velocity_field(psi)
    xlim=ylim=(-3,3)
    fig, ax=plt.subplots(figsize=(4, 4))
    plot_streamlines(ax, u, v, xlim, ylim)
    c=plt.Circle((0,0), radius=1,facecolor='none')
    ax.add_patch(c)

    format_axes(ax)
Lior Cohen

you have not

plt.show()

thus rendering and preventing the program from exiting.

Related


How can I fix my python code to draw the graph?

Joseph Tannuri My code exits with code 0, so my code has no errors, but it's still running without drawing the flow on the cylinder I want, can anyone help me with this? import sympy as s import matplotlib.pyplot as plt import numpy as np from

How can I fix my python code to draw the graph?

Joseph Tannuri My code exits with code 0, so my code has no errors, but it's still running without drawing the flow on the cylinder I want, can anyone help me with this? import sympy as s import matplotlib.pyplot as plt import numpy as np from

How can I fix my python code to draw the graph?

Joseph Tannuri My code exits with code 0, so my code has no errors, but it's still running without drawing the flow on the cylinder I want, can anyone help me with this? import sympy as s import matplotlib.pyplot as plt import numpy as np from

How can I fix my python code to draw the graph?

Joseph Tannuri My code exits with code 0, so my code has no errors, but it's still running without drawing the flow on the cylinder I want, can anyone help me with this? import sympy as s import matplotlib.pyplot as plt import numpy as np from

How can I draw such a graph in Python?

Santos I want to draw a graph like the image below: I wrote the following code to plot the waveform for each time step. import matplotlib.pyplot as plt import numpy as np def u_0(x): a = 1.0/np.cosh(2.0*(x+8.0)) b = 1.0/np.cosh((x+1.0)) return 8.0

How can I draw such a graph in Python?

Santos I want to draw a graph like the image below: I wrote the following code to plot the waveform for each time step. import matplotlib.pyplot as plt import numpy as np def u_0(x): a = 1.0/np.cosh(2.0*(x+8.0)) b = 1.0/np.cosh((x+1.0)) return 8.0

How can I fix this error in my python code?

User 12316458 The code is available on github in python 2, so I changed it a bit, but now, it says there is a syntax error and I don't know how to fix it. Code: import sys import os import time import socket import random #Code from datetime import datetime n

How can I fix my code to automate it?

imaginative I have the following code which .txtperfectly converts my normalized file to JSON file. The only problem is that sometimes I have more than 300 files and doing this manually (ie changing the numbers at the end of the file and running the script is

How can I fix the code used to draw the histogram?

request20 Sorry if this is the basics, I'm new to R and starting here. I would like to plot a histogram of the following data (each sample has a Shannon diversity metric representing the abundance and abundance of species in each sample). Here is my data, curr

How can I fix the code used to draw the histogram?

request20 Sorry if this is the basics, I'm new to R and starting here. I would like to plot a histogram of the following data (each sample has a Shannon diversity metric representing the abundance and abundance of species in each sample). Here is my data, curr

How can I fix the code used to draw the histogram?

request20 Sorry if this is the basics, I'm new to R and starting here. I would like to plot a histogram of the following data (each sample has a Shannon diversity metric representing the abundance and abundance of species in each sample). Here is my data, curr

How can I fix the code used to draw the histogram?

request20 Sorry if this is the basics, I'm new to R and starting here. I would like to plot a histogram of the following data (each sample has a Shannon diversity metric representing the abundance and abundance of species in each sample). Here is my data, curr

How can I fix the code used to draw the histogram?

request20 Sorry if this is the basics, I'm new to R and starting here. I would like to plot a histogram of the following data (each sample has a Shannon diversity metric representing the abundance and abundance of species in each sample). Here is my data, curr

How can I draw a control flow graph from this code?

learn math int main() { int i, grade = 0; printf (" Enter points: \n"); scanf ("%d", &i); if (i >= 50 && i <= 60) grade = 5; else if (i > 50 && i <= 60) grade = 6; else if (i > 60 && i <= 70) grade = 7; else if (i > 70 && i <= 80) g

How can I draw a control flow graph from this code?

learn math int main() { int i, grade = 0; printf (" Enter points: \n"); scanf ("%d", &i); if (i >= 50 && i <= 60) grade = 5; else if (i > 50 && i <= 60) grade = 6; else if (i > 60 && i <= 70) grade = 7; else if (i > 70 && i <= 80) g

How can I draw a control flow graph from this code?

learn math int main() { int i, grade = 0; printf (" Enter points: \n"); scanf ("%d", &i); if (i >= 50 && i <= 60) grade = 5; else if (i > 50 && i <= 60) grade = 6; else if (i > 60 && i <= 70) grade = 7; else if (i > 70 && i <= 80) g

How can I draw a control flow graph from this code?

learn math int main() { int i, grade = 0; printf (" Enter points: \n"); scanf ("%d", &i); if (i >= 50 && i <= 60) grade = 5; else if (i > 50 && i <= 60) grade = 6; else if (i > 60 && i <= 70) grade = 7; else if (i > 70 && i <= 80) g

How can I draw a control flow graph from this code?

learn math int main() { int i, grade = 0; printf (" Enter points: \n"); scanf ("%d", &i); if (i >= 50 && i <= 60) grade = 5; else if (i > 50 && i <= 60) grade = 6; else if (i > 60 && i <= 70) grade = 7; else if (i > 70 && i <= 80) g

How can I draw a control flow graph from this code?

learn math int main() { int i, grade = 0; printf (" Enter points: \n"); scanf ("%d", &i); if (i >= 50 && i <= 60) grade = 5; else if (i > 50 && i <= 60) grade = 6; else if (i > 60 && i <= 70) grade = 7; else if (i > 70 && i <= 80) g

How can I draw a control flow graph from this code?

learn math int main() { int i, grade = 0; printf (" Enter points: \n"); scanf ("%d", &i); if (i >= 50 && i <= 60) grade = 5; else if (i > 50 && i <= 60) grade = 6; else if (i > 60 && i <= 70) grade = 7; else if (i > 70 && i <= 80) g

How can I draw an energy ranking graph using Python?

twin penguins This is a typical energy ranking used in some published papers, and I am struggling to reproduce one for my data using Python (any matplotlib, sns, etc.). I structure the data in a Pandas dataframe like this: System Color_id Data1 Data2 Form I

How can I draw an energy ranking graph using Python?

twin penguins This is a typical energy ranking used in some published papers, and I am struggling to reproduce one for my data using Python (any matplotlib, sns, etc.). I structure the data in a Pandas dataframe like this: System Color_id Data1 Data2 Form I

How can I draw an energy ranking graph using Python?

twin penguins This is a typical energy ranking used in some published papers, and I am struggling to reproduce one for my data using Python (any matplotlib, sns, etc.). I structure the data in a Pandas dataframe like this: System Color_id Data1 Data2 Form I

How can I fix my error code program? I am using Python 3.6

username How to fix this error I am using Python 3.6 and Database Oracle, I want to print data from database, but it shows error, how can I fix it? This is my database: enter image description here EMPLOYEESID (primary key), NIK (unique key) Here is my code: #

How can I fix my error code program? I am using Python 3.6

username How to fix this error I am using Python 3.6 and Database Oracle, I want to print data from database, but it shows error, how can I fix it? This is my database: enter image description here EMPLOYEESID (primary key), NIK (unique key) Here is my code: #

My Newton Gradle code is not working. How can I fix this?

Cool kids: PVector start1; PVector end1; PVector start2; PVector end2; float e = 0; //angle float l = 350; //length float add = 0.05;//add(to angle) float e2 = 0;//other angle float add2 = 0; //add to second angle void setup() { //setup the canvas size(1

How can I fix my code to display a table?

big mother I'm trying to render my dynamic JSON, but I get a table when each result should be rendered in the same table. .How is this going? My dummy array is a model for my backend API const arr = [ { "Demo": [ { "_id": "T0821

How can I fix my code to make it work correctly?

overflow I'm new to PHP (and programming in general). I saw a video explaining the basics, so I decided to play with PHP myself; I wrote this code: <?php $people = [ array("John", "smart"), array("Mike", "dumb"), array("Jose", "smart"), arr

How can I fix my code to display a table?

big mother I'm trying to render my dynamic JSON, but I get a table when each result should be rendered in the same table. .How is this going? My dummy array is a model for my backend API const arr = [ { "Demo": [ { "_id": "T0821