{"id":1723,"date":"2022-12-14T09:18:51","date_gmt":"2022-12-14T17:18:51","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1723"},"modified":"2022-12-14T09:18:52","modified_gmt":"2022-12-14T17:18:52","slug":"204-mandelbrot-fractal-using-python-2-2-2-2-2-2-2","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2022\/12\/204-mandelbrot-fractal-using-python-2-2-2-2-2-2-2\/","title":{"rendered":"#326 Vertical box plot using python"},"content":{"rendered":"<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport pandas as pd\r\ndf = pd.DataFrame(np.random.rand(10, 5),columns=&#x5B;'A', 'B', 'C', 'D', 'E'])\r\ncolor = dict(boxes='DarkGreen', whiskers='Red', medians='Blue', caps='Gray')\r\nplt.figure()\r\ndf.plot.box(color=color, sym='r+')\r\nplt.savefig('ex326.png', dpi=100)\r\nplt.show()\r\n<\/pre>\n<p><a href=\"https:\/\/gantovnik.com\/bio-tips\/2022\/12\/204-mandelbrot-fractal-using-python-2-2-2-2-2-2-2\/ex326\/\" rel=\"attachment wp-att-1724\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/12\/ex326.png?resize=600%2C400&#038;ssl=1\" alt=\"\" width=\"600\" height=\"400\" class=\"alignnone size-full wp-image-1724\" srcset=\"https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/12\/ex326.png 600w, https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/12\/ex326-480x320.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 600px, 100vw\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>import numpy as np import matplotlib.pyplot as plt import pandas as pd df = pd.DataFrame(np.random.rand(10, 5),columns=&#x5B;&#8217;A&#8217;, &#8216;B&#8217;, &#8216;C&#8217;, &#8216;D&#8217;, &#8216;E&#8217;]) color = dict(boxes=&#8217;DarkGreen&#8217;, whiskers=&#8217;Red&#8217;, medians=&#8217;Blue&#8217;, caps=&#8217;Gray&#8217;) plt.figure() df.plot.box(color=color, sym=&#8217;r+&#8217;) plt.savefig(&#8216;ex326.png&#8217;, 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_post_was_ever_published":false,"_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":""},"categories":[2],"tags":[3],"class_list":["post-1723","post","type-post","status-publish","format-standard","hentry","category-python","tag-python"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-rN","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1002,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/10\/180-linear-regression-using-python\/","url_meta":{"origin":1723,"position":0},"title":"#180 Linear regression using python","author":"gantovnik","date":"2021-10-26","format":false,"excerpt":"[code language=\"python\"] import os import matplotlib.pyplot as plt import numpy as np import seaborn as sns from sklearn.linear_model import LinearRegression sns.set() os.chdir(r'D:\\projects\\wordpress\\ex66') os.getcwd() rng = np.random.RandomState(1) x = 10 * rng.rand(50) y = 2 * x - 5 + rng.randn(50) plt.scatter(x, y) model = LinearRegression(fit_intercept=True) model.fit(x[:, np.newaxis], y) xfit =\u2026","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\/10\/ex180.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex180.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex180.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1875,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/06\/354-animation-in-python\/","url_meta":{"origin":1723,"position":1},"title":"#354 Animation in python","author":"gantovnik","date":"2023-06-30","format":false,"excerpt":"[code language=\"python\"] # pip install celluloid #%matplotlib qt from matplotlib import pyplot as plt from celluloid import Camera import numpy as np fig, axes = plt.subplots(2) camera = Camera(fig) t = np.linspace(0, 2.0*np.pi, 128, endpoint=False) for i in t: axes[0].plot(t, np.sin(t + i), color='blue') axes[1].plot(t, np.sin(t - i), color='blue') camera.snap()\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\/2023\/06\/ex354.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/06\/ex354.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/06\/ex354.gif?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2219,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/06\/431-hypermesh-python-script-to-create-nodes-using-coordinates-from-csv-file\/","url_meta":{"origin":1723,"position":2},"title":"#431 HyperMesh python script to create nodes using coordinates from csv file","author":"gantovnik","date":"2024-06-24","format":false,"excerpt":"Finally, I read how to write a script for HyperMesh in python. In this example, the script reads the coordinates of points from a cvs file. [code language=\"python\"] import os import hm import hm.entities as e from hwx import gui import csv model=hm.Model() os.chdir(r\"D:\\projects\\wordpress\\ex431\") with open('ex431_coordinates.csv', mode ='r') as file:\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/06\/ex431.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2127,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/02\/414-how-to-remove-gaps-between-subplots-in-python\/","url_meta":{"origin":1723,"position":3},"title":"#414 How to remove gaps between subplots in python?","author":"gantovnik","date":"2024-02-20","format":false,"excerpt":"[code language=\"python\"] import matplotlib.pyplot as plt import numpy as np fig, axes = plt.subplots(1, 2, sharey=True) xx = np.linspace(-10, 10, 1000) [ax.grid() for ax in axes] axes[0].plot(np.sin(xx * xx), color=\"blue\") axes[1].plot(np.cos(xx) * xx, color=\"red\") fig.subplots_adjust(wspace=0) # no horizontal space plt.savefig(\"ex414.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\/ex414.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex414.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex414.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2131,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/02\/415-tight_layout-in-matplotlib-in-python\/","url_meta":{"origin":1723,"position":4},"title":"#415 tight_layout() in matplotlib in python","author":"gantovnik","date":"2024-02-20","format":false,"excerpt":"[code language=\"python\"] import matplotlib.pyplot as plt import numpy as np fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(10,3)) xx = np.linspace(1, 20, 1000) yy = np.log(xx**2 + 1) * np.sin(xx) + xx ax1.plot(xx, yy) ax2.scatter(sorted(xx), sorted(yy), s=1, marker=\".\", color=\"green\") ax3.hist(yy, bins=20, color=\"red\",edgecolor='black', alpha=.5) fig.tight_layout() plt.savefig(\"ex415.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\/ex415.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex415.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex415.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/02\/ex415.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":370,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/roots-of-equation\/","url_meta":{"origin":1723,"position":5},"title":"#52 Roots of equation using python","author":"gantovnik","date":"2019-01-29","format":false,"excerpt":"[code language=\"python\"] import os import numpy as np import matplotlib.pyplot as plt from scipy.optimize import brentq os.chdir(r'D:\\projects\\wordpress\\ex52') os.getcwd() f=lambda x: 0.2+x * np.cos(3\/x) x=np.linspace(-1,1,1000) plt.plot(x,f(x)) plt.axhline(0,color='k') xstar=brentq(f,-0.7,-0.5) print(xstar,f(xstar)) plt.plot(xstar,f(xstar), 'ro') plt.text(-1.0, -0.5, 'x=%6.4f and f(x)=%6.4f' % (xstar, f(xstar))) plt.tight_layout() plt.savefig(\"example52.png\", dpi=300) plt.show() plt.close() [\/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\/2019\/01\/example62.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example62.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example62.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1723","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=1723"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1723\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}