{"id":2140,"date":"2024-02-21T01:05:57","date_gmt":"2024-02-21T09:05:57","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=2140"},"modified":"2024-02-21T01:05:57","modified_gmt":"2024-02-21T09:05:57","slug":"417-polar-plot-using-sympy-plotting-functions-in-python","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2024\/02\/417-polar-plot-using-sympy-plotting-functions-in-python\/","title":{"rendered":"#417 Polar plot using SymPy plotting functions in python"},"content":{"rendered":"<p><a href=\"https:\/\/gantovnik.com\/bio-tips\/2024\/02\/417-polar-plot-using-sympy-plotting-functions-in-python\/ex417\/\" rel=\"attachment wp-att-2141\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex417.png?resize=800%2C800&#038;ssl=1\" alt=\"\" width=\"800\" height=\"800\" class=\"alignnone size-full wp-image-2141\" srcset=\"https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex417.png 800w, https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex417-480x480.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 800px, 100vw\" \/><\/a><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport matplotlib.pyplot as plt\r\nfrom sympy import symbols, sin, cos, pi, latex\r\nfrom spb import plot_polar\r\n\r\nx = symbols(&quot;x&quot;)\r\nexpr = sin(2 * x) * cos(5 * x) + pi \/ 2\r\nplot_polar(expr, (x, 0, 2 * pi),\r\n    polar_axis=True, ylim=(0, 3), title=&quot;$%s$&quot; % latex(expr))\r\n\r\nplt.savefig(&quot;ex417.png&quot;, dpi=100)\r\nplt.show()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import matplotlib.pyplot as plt from sympy import symbols, sin, cos, pi, latex from spb import plot_polar x = symbols(&quot;x&quot;) expr = sin(2 * x) * cos(5 * x) + pi \/ 2 plot_polar(expr, (x, 0, 2 * pi), polar_axis=True, ylim=(0, 3), title=&quot;$%s$&quot; % latex(expr)) plt.savefig(&quot;ex417.png&quot;, dpi=100) plt.show()<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[69,91,2],"tags":[],"class_list":["post-2140","post","type-post","status-publish","format-standard","hentry","category-matplotlib","category-plot","category-python"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-yw","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":2135,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/02\/416-plot-using-sympy-in-python\/","url_meta":{"origin":2140,"position":0},"title":"#416 Plot using sympy and plot_implicit in python","author":"gantovnik","date":"2024-02-21","format":false,"excerpt":"[code language=\"python\"] import matplotlib.pyplot as plt from sympy import symbols, plot_implicit, And plt.rcParams[\"figure.figsize\"] = (8,8) x,y=symbols('x y') p = plot_implicit(And( x**2 + y**2 < 25, x**2 + y**2 > 10,), (x,-10, 10), (y, -10, 10)) plt.savefig(\"ex416.png\", dpi=100) plt.show() [\/code]","rel":"","context":"In &quot;matplotlib&quot;","block_context":{"text":"matplotlib","link":"https:\/\/gantovnik.com\/bio-tips\/category\/matplotlib\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex416.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex416.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex416.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex416.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1139,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/200-plot-in-matplotlib\/","url_meta":{"origin":2140,"position":1},"title":"#200 Plot in matplotlib","author":"gantovnik","date":"2021-11-22","format":false,"excerpt":"[code language=\"python\"] # Plot in matplotlib import numpy as np import matplotlib.pyplot as plt from math import pi x = np.linspace(-2.0*pi,2.0*pi,200) plt.plot(x,np.sin(x)) samples=x[::2] plt.plot(samples,np.sin(samples),'r*') plt.title('Function sin(x) and some points plotted') plt.grid() plt.xlabel(\"x\") plt.ylabel(\"y\") plt.savefig('ex200.png', dpi=72) plt.show() [\/code]","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex200.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex200.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex200.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex200.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":926,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/06\/166-solution-of-a-differential-equation-using-bubnov-galerkin-method-with-sympy-package\/","url_meta":{"origin":2140,"position":2},"title":"#166 Solution of a differential equation using Bubnov-Galerkin method with Sympy package","author":"gantovnik","date":"2021-06-15","format":false,"excerpt":"#166 Solution of a differential equation using Bubnov-Galerkin method with Sympy package The problem and solution in this pdf file: ex166 [code language=\"python\"] import sympy from matplotlib import pyplot as plt import seaborn as sns import numpy as np from sympy.utilities.lambdify import lambdify from sympy import simplify from sympy import\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":143,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/143\/","url_meta":{"origin":2140,"position":3},"title":"#30 Newton&#8217;s Law of Cooling","author":"gantovnik","date":"2019-01-06","format":false,"excerpt":"import os import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl mpl.rcParams['text.usetex'] = True import sympy from IPython.display import display sympy.init_printing() #%matplotlib inline #%config InlineBackend.figure_format='retina' os.chdir(r'D:\\projects\\wordpress\\ex30') os.getcwd() #Symbolic ODE solving with SymPy #Newton's law of cooling t, k, T0, Ta = sympy.symbols(\"t, k, T_0, T_a\") T =\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example30","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example30.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example30.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example30.png?resize=525%2C300 1.5x"},"classes":[]},{"id":365,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/solution-of-laplace-equation-using-fem\/","url_meta":{"origin":2140,"position":4},"title":"#51 Solution of Laplace equation using FEM","author":"gantovnik","date":"2019-01-29","format":false,"excerpt":"[code language=\"python\"] import os import matplotlib.pyplot as plt import numpy as np from numpy import linspace from scipy.spatial import Delaunay from numpy import cross from scipy.sparse import dok_matrix import matplotlib.cm as cm os.chdir(r'D:\\projects\\wordpress\\ex51') os.getcwd() xmin = 0 ; xmax = 1 ; nXpoints = 10 ymin = 0 ; ymax\u2026","rel":"","context":"In &quot;fem&quot;","block_context":{"text":"fem","link":"https:\/\/gantovnik.com\/bio-tips\/category\/fem\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example61_3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example61_3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example61_3.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3022,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/07\/442-the-partial-sums-of-the-fourier-series-for-the-square-wave-function-using-python\/","url_meta":{"origin":2140,"position":5},"title":"#442 The partial sums of the Fourier series for the square-wave function using python","author":"gantovnik","date":"2024-07-25","format":false,"excerpt":"import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Slider nmax = 5 pi = np.pi x = np.linspace(-2*pi, 2*pi, 1001) def f(xarray): y = np.zeros_like(xarray) for ind, x in enumerate(xarray): xmod = x%(2*pi) if xmod<pi: y[ind] = 1 if x%pi==0: y[ind]= np.nan return y def Fourier(x, nmax):\u2026","rel":"","context":"In &quot;animation&quot;","block_context":{"text":"animation","link":"https:\/\/gantovnik.com\/bio-tips\/category\/animation\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/07\/ex442_3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/07\/ex442_3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/07\/ex442_3.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/2140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=2140"}],"version-history":[{"count":2,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/2140\/revisions"}],"predecessor-version":[{"id":2143,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/2140\/revisions\/2143"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=2140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=2140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=2140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}