{"id":1185,"date":"2021-11-27T04:16:45","date_gmt":"2021-11-27T12:16:45","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1185"},"modified":"2021-11-27T04:16:45","modified_gmt":"2021-11-27T12:16:45","slug":"204-mandelbrot-fractal-using-python-2-2-2","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/204-mandelbrot-fractal-using-python-2-2-2\/","title":{"rendered":"#207 Zoom region inset axes"},"content":{"rendered":"<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfrom matplotlib import cbook\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\ndef get_demo_image():\r\n    z = cbook.get_sample_data(&quot;axes_grid\/bivariate_normal.npy&quot;, np_load=True)\r\n    # z is a numpy array of 15x15\r\n    return z, (-3, 4, -4, 3)\r\n\r\nfig, ax = plt.subplots(figsize=&#x5B;5, 4])\r\n# make data\r\nZ, extent = get_demo_image()\r\nZ2 = np.zeros((150, 150))\r\nny, nx = Z.shape\r\nZ2&#x5B;30:30+ny, 30:30+nx] = Z\r\nax.imshow(Z2, extent=extent, origin=&quot;lower&quot;)\r\n# inset axes....\r\naxins = ax.inset_axes(&#x5B;0.5, 0.5, 0.47, 0.47])\r\naxins.imshow(Z2, extent=extent, origin=&quot;lower&quot;)\r\n# sub region of the original image\r\nx1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9\r\naxins.set_xlim(x1, x2)\r\naxins.set_ylim(y1, y2)\r\naxins.set_xticklabels(&#x5B;])\r\naxins.set_yticklabels(&#x5B;])\r\nax.indicate_inset_zoom(axins, edgecolor=&quot;black&quot;)\r\nplt.savefig('ex207.png', dpi=72)\r\nplt.show()\r\n<\/pre>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex207.png?resize=360%2C288&#038;ssl=1\" alt=\"\" width=\"360\" height=\"288\" class=\"alignnone size-full wp-image-1186\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex207.png?w=360&amp;ssl=1 360w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex207.png?resize=300%2C240&amp;ssl=1 300w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex207.png?resize=150%2C120&amp;ssl=1 150w\" sizes=\"(max-width: 360px) 100vw, 360px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>from matplotlib import cbook import matplotlib.pyplot as plt import numpy as np def get_demo_image(): z = cbook.get_sample_data(&quot;axes_grid\/bivariate_normal.npy&quot;, np_load=True) # z is a numpy array of 15&#215;15 return z, (-3, 4, -4, 3) fig, ax = plt.subplots(figsize=&#x5B;5, 4]) # make data Z, extent = get_demo_image() Z2 = np.zeros((150, 150)) ny, nx = Z.shape Z2&#x5B;30:30+ny, 30:30+nx] = [&hellip;]<\/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":[],"class_list":["post-1185","post","type-post","status-publish","format-standard","hentry","category-python"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-j7","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1984,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/12\/398-find-points-of-intersection-of-two-circles\/","url_meta":{"origin":1185,"position":0},"title":"#398 Find points of intersection of two circles","author":"gantovnik","date":"2023-12-26","format":false,"excerpt":"- how to find an equation of the common chord of two intersected circles. [code language=\"python\"] import numpy as np import matplotlib.pyplot as plt import math def get_intersections(x0, y0, r0, x1, y1, r1): # circle 1: (x0, y0), radius r0 # circle 2: (x1, y1), radius r1 d=math.sqrt((x1-x0)**2 + (y1-y0)**2)\u2026","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\/2023\/12\/ex398.png?fit=640%2C480&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/12\/ex398.png?fit=640%2C480&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/12\/ex398.png?fit=640%2C480&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":1208,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/210-parametric-curve-in-3d-2-2-2\/","url_meta":{"origin":1185,"position":1},"title":"#213 Annotate Text Arrow","author":"gantovnik","date":"2021-11-27","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt # Fixing random state for reproducibility np.random.seed(19680801) fig, ax = plt.subplots(figsize=(5, 5)) ax.set_aspect(1) x1 = -1 + np.random.randn(100) y1 = -1 + np.random.randn(100) x2 = 1. + np.random.randn(100) y2 = 1. + np.random.randn(100) ax.scatter(x1, y1, color=\"r\") ax.scatter(x2, y2, color=\"g\") bbox_props\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\/11\/ex213.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":193,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/double-pendulum\/","url_meta":{"origin":1185,"position":2},"title":"#39 Double pendulum using python","author":"gantovnik","date":"2019-01-10","format":false,"excerpt":"import os import numpy as np import matplotlib.pyplot as plt from scipy import integrate import sympy os.chdir(r'D:\\projects\\wordpress\\ex39') os.getcwd() t, g, m1, l1, m2, l2 = sympy.symbols(\"t, g, m_1, l_1, m_2, l_2\") theta1, theta2 = sympy.symbols(\"theta_1, theta_2\", cls=sympy.Function) ode1 = sympy.Eq((m1+m2)*l1 * theta1(t).diff(t,t) + m2*l2 * theta2(t).diff(t,t) + m2*l2 * theta2(t).diff(t)**2\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example39","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example39.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example39.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example39.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2104,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/01\/411-clustering-using-dbscan-algorithm-in-sklearn-cluster-in-python\/","url_meta":{"origin":1185,"position":3},"title":"#411 Clustering using DBSCAN algorithm in sklearn.cluster in python","author":"gantovnik","date":"2024-01-18","format":false,"excerpt":"DBSCAN works by finding core points that have many data points within a given radius. Once the core is defined, the process is iteratively computed until there are no more core points definable within the maximum radius. This algorithm does exceptionally well compared to kmeans where there is noise present\u2026","rel":"","context":"In &quot;cluster&quot;","block_context":{"text":"cluster","link":"https:\/\/gantovnik.com\/bio-tips\/category\/cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex411.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1204,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/210-parametric-curve-in-3d-2-2\/","url_meta":{"origin":1185,"position":4},"title":"#212 The double pendulum simulation using python","author":"gantovnik","date":"2021-11-27","format":false,"excerpt":"[code language=\"python\"] from numpy import sin, cos import numpy as np import matplotlib.pyplot as plt import scipy.integrate as integrate import matplotlib.animation as animation from collections import deque G = 9.8 # acceleration due to gravity, in m\/s^2 L1 = 1.0 # length of pendulum 1 in m L2 = 1.0\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\/2021\/11\/ex212.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1975,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/11\/395-parameters-of-free-shape-optimization-in-hypermesh\/","url_meta":{"origin":1185,"position":5},"title":"#395 Parameters of Free Shape Optimization in HyperMesh","author":"gantovnik","date":"2023-11-11","format":false,"excerpt":"Transition Zone NTRANS When the entire surface or edge of a system is not a design zone and both design and non-design regions exist adjacent to one another, a transition zone can be defined using NTRANS which helps to smooth out the transition. Sharp changes can occur in the design\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1185","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=1185"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1185\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}