{"id":1917,"date":"2023-08-10T03:14:36","date_gmt":"2023-08-10T10:14:36","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1917"},"modified":"2023-08-10T15:09:39","modified_gmt":"2023-08-10T22:09:39","slug":"374-hexbin-plot-with-marginal-distributions-using-seaborn-library","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/374-hexbin-plot-with-marginal-distributions-using-seaborn-library\/","title":{"rendered":"#374 Hexbin plot with marginal distributions using seaborn library"},"content":{"rendered":"<p><a href=\"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/374-hexbin-plot-with-marginal-distributions-using-seaborn-library\/ex374\/\" rel=\"attachment wp-att-1918\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex374.png?resize=600%2C600&#038;ssl=1\" alt=\"\" width=\"600\" height=\"600\" class=\"alignnone size-full wp-image-1918\" srcset=\"https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex374.png 600w, https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex374-480x480.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 600px, 100vw\" \/><\/a><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n#conda install -c anaconda seaborn\r\nimport seaborn as sns\r\nsns.set_theme(style=&quot;ticks&quot;)\r\n\r\ndef main():\r\n    rs = np.random.RandomState(11)\r\n    x = rs.gamma(2, size=1000)\r\n    y = -.5 * x + rs.normal(size=1000)\r\n    sns.jointplot(x=x, y=y, kind=&quot;hex&quot;, color=&quot;#4CB323&quot;)\r\n    plt.savefig(&quot;ex374.png&quot;, dpi=100)\r\n    plt.show()\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import numpy as np import matplotlib.pyplot as plt #conda install -c anaconda seaborn import seaborn as sns sns.set_theme(style=&quot;ticks&quot;) def main(): rs = np.random.RandomState(11) x = rs.gamma(2, size=1000) y = -.5 * x + rs.normal(size=1000) sns.jointplot(x=x, y=y, kind=&quot;hex&quot;, color=&quot;#4CB323&quot;) plt.savefig(&quot;ex374.png&quot;, dpi=100) plt.show() if __name__ == &#8216;__main__&#8217;: main()<\/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":[91,2,92],"tags":[],"class_list":["post-1917","post","type-post","status-publish","format-standard","hentry","category-plot","category-python","category-seaborn"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-uV","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1947,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/387-replot-in-seaborn-library\/","url_meta":{"origin":1917,"position":0},"title":"#387 Replot() in seaborn library","author":"gantovnik","date":"2023-08-13","format":false,"excerpt":"[code language=\"python\"] #Replot() in seaborn library import matplotlib.pyplot as plt #conda install -c anaconda seaborn import seaborn as sns # Apply the default theme sns.set_theme() def main(): # Load an example dataset tips = sns.load_dataset(\"tips\") # Create a visualization sns.relplot( data=tips, x=\"total_bill\", y=\"tip\", col=\"time\", hue=\"smoker\", style=\"smoker\", size=\"size\", ) plt.savefig(\"ex387.png\", dpi=100)\u2026","rel":"","context":"In &quot;plot&quot;","block_context":{"text":"plot","link":"https:\/\/gantovnik.com\/bio-tips\/category\/plot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex387.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex387.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex387.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex387.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex387.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1923,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/377-stacked-histogram-on-a-log-scale-using-seaborn\/","url_meta":{"origin":1917,"position":1},"title":"#377 Stacked histogram on a log scale using seaborn library","author":"gantovnik","date":"2023-08-10","format":false,"excerpt":"[code language=\"python\"] #Stacked histogram on a log scale import matplotlib.pyplot as plt import matplotlib as mpl #conda install -c anaconda seaborn import seaborn as sns sns.set_theme(style=\"ticks\") def main(): diamonds = sns.load_dataset(\"diamonds\") f, ax = plt.subplots(figsize=(7, 5)) sns.despine(f) sns.histplot( diamonds, x=\"price\", hue=\"cut\", multiple=\"stack\", palette=\"light:m_r\", edgecolor=\".3\", linewidth=.5, log_scale=True, ) ax.xaxis.set_major_formatter(mpl.ticker.ScalarFormatter()) ax.set_xticks([500, 1000,\u2026","rel":"","context":"In &quot;plot&quot;","block_context":{"text":"plot","link":"https:\/\/gantovnik.com\/bio-tips\/category\/plot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex377.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex377.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex377.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex377.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1919,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/375-regression-fit-over-a-strip-plot-using-seaborn-library\/","url_meta":{"origin":1917,"position":2},"title":"#375 Regression fit over a strip plot using seaborn library","author":"gantovnik","date":"2023-08-10","format":false,"excerpt":"[code language=\"python\"] #Regression fit over a strip plot import matplotlib.pyplot as plt #conda install -c anaconda seaborn import seaborn as sns sns.set_theme() def main(): mpg = sns.load_dataset(\"mpg\") sns.catplot( data=mpg, x=\"cylinders\", y=\"acceleration\", hue=\"weight\", native_scale=True, zorder=1 ) sns.regplot( data=mpg, x=\"cylinders\", y=\"acceleration\", scatter=False, truncate=False, order=2, color=\".2\", ) plt.savefig(\"ex375.png\", dpi=100) plt.show() if __name__ ==\u2026","rel":"","context":"In &quot;plot&quot;","block_context":{"text":"plot","link":"https:\/\/gantovnik.com\/bio-tips\/category\/plot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/11\/ex394.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/11\/ex394.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/11\/ex394.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1927,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/378-horizontal-boxplot-with-observations-using-seaborn-library\/","url_meta":{"origin":1917,"position":3},"title":"#378 Horizontal boxplot with observations using seaborn library","author":"gantovnik","date":"2023-08-10","format":false,"excerpt":"[code language=\"python\"] #Horizontal boxplot with observations import matplotlib.pyplot as plt #conda install -c anaconda seaborn import seaborn as sns sns.set_theme(style=\"ticks\") def main(): # Initialize the figure with a logarithmic x axis f, ax = plt.subplots(figsize=(7, 6)) ax.set_xscale(\"log\") # Load the example planets dataset planets = sns.load_dataset(\"planets\") # Plot the orbital\u2026","rel":"","context":"In &quot;plot&quot;","block_context":{"text":"plot","link":"https:\/\/gantovnik.com\/bio-tips\/category\/plot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex378.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex378.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex378.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex378.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1915,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/373-scatterplot-with-multiple-semantics-using-seaborn-library\/","url_meta":{"origin":1917,"position":4},"title":"#373 Scatterplot with multiple semantics using seaborn library","author":"gantovnik","date":"2023-08-09","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt import os from scipy.special import fresnel #conda install -c anaconda seaborn import seaborn as sns sns.set_theme(style=\"whitegrid\") def main(): # Load the example diamonds dataset diamonds = sns.load_dataset(\"diamonds\") # Draw a scatter plot while assigning point colors and sizes to different\u2026","rel":"","context":"In &quot;plot&quot;","block_context":{"text":"plot","link":"https:\/\/gantovnik.com\/bio-tips\/category\/plot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1938,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/383-horizontal-bar-plot-using-seaborn-library\/","url_meta":{"origin":1917,"position":5},"title":"#383 Horizontal bar plot using seaborn library","author":"gantovnik","date":"2023-08-11","format":false,"excerpt":"[code language=\"python\"] #Horizontal bar plot using seaborn library import matplotlib.pyplot as plt #conda install -c anaconda seaborn import seaborn as sns sns.set_theme(style=\"whitegrid\") def main(): # Initialize the matplotlib figure f, ax = plt.subplots(figsize=(6, 15)) # Load the example car crash dataset crashes = sns.load_dataset(\"car_crashes\").sort_values(\"total\", ascending=False) # Plot the total crashes\u2026","rel":"","context":"In &quot;plot&quot;","block_context":{"text":"plot","link":"https:\/\/gantovnik.com\/bio-tips\/category\/plot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex383.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex383.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex383.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1917","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=1917"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1917\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}