{"id":1861,"date":"2023-06-27T02:30:27","date_gmt":"2023-06-27T09:30:27","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1861"},"modified":"2023-06-27T02:30:27","modified_gmt":"2023-06-27T09:30:27","slug":"349-modify-tick-label-text","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2023\/06\/349-modify-tick-label-text\/","title":{"rendered":"#349 Modify tick label text"},"content":{"rendered":"<p><a href=\"https:\/\/gantovnik.com\/bio-tips\/2023\/06\/349-modify-tick-label-text\/ex349\/\" rel=\"attachment wp-att-1862\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/06\/ex349.png?resize=432%2C288&#038;ssl=1\" alt=\"\" width=\"432\" height=\"288\" class=\"alignnone size-full wp-image-1862\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/06\/ex349.png?w=432&amp;ssl=1 432w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/06\/ex349.png?resize=300%2C200&amp;ssl=1 300w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/06\/ex349.png?resize=150%2C100&amp;ssl=1 150w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/a><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\nfig, ax = plt.subplots()\r\nx = np.linspace(0, 4 * np.pi, 600)\r\ny = np.sin(x)\r\nax.plot(x,y)\r\nticklabels = &#x5B;'{:,.0f}'.format(x) for x in ax.get_xticks()]\r\nax.set_xticklabels(ticklabels)\r\nlabels = &#x5B;item.get_text() for item in ax.get_xticklabels()]\r\nprint(labels)\r\nlabels&#x5B;1] = 'A1'\r\nlabels&#x5B;3] = 'A3'\r\nax.set_xticklabels(labels)\r\nplt.savefig('ex349.png', dpi=72)\r\nplt.show()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots() x = np.linspace(0, 4 * np.pi, 600) y = np.sin(x) ax.plot(x,y) ticklabels = &#x5B;'{:,.0f}&#8217;.format(x) for x in ax.get_xticks()] ax.set_xticklabels(ticklabels) labels = &#x5B;item.get_text() for item in ax.get_xticklabels()] print(labels) labels&#x5B;1] = &#8216;A1&#8217; labels&#x5B;3] = &#8216;A3&#8217; ax.set_xticklabels(labels) plt.savefig(&#8216;ex349.png&#8217;, dpi=72) 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":[69,2],"tags":[],"class_list":["post-1861","post","type-post","status-publish","format-standard","hentry","category-matplotlib","category-python"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-u1","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":2007,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/01\/401-add-labels-to-line-plot-in-python\/","url_meta":{"origin":1861,"position":0},"title":"#401 Add labels to line plot in python","author":"gantovnik","date":"2024-01-05","format":false,"excerpt":"[code language=\"python\"] import matplotlib.pyplot as plt import numpy as np plt.clf() # using some dummy data for this example n = 25 xs = np.linspace(1, 100, num=n) ys = np.random.normal(loc=3, scale=0.4, size=n) # 'bo-' means blue color, round points, solid lines plt.plot(xs,ys,'bo-') # zip joins x and y coordinates in\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\/2024\/01\/ex401.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\/2024\/01\/ex401.png?fit=640%2C480&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex401.png?fit=640%2C480&ssl=1&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":1861,"position":1},"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":1188,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/204-mandelbrot-fractal-using-python-2-2-2-2\/","url_meta":{"origin":1861,"position":2},"title":"#208 Scatter plot with histograms using python","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) some random data x = np.random.randn(1000) y = np.random.randn(1000) def scatter_hist(x, y, ax, ax_histx, ax_histy): # no labels ax_histx.tick_params(axis=\"x\", labelbottom=False) ax_histy.tick_params(axis=\"y\", labelleft=False) # the scatter plot: ax. Scatter(x, y,s=3) # now determine nice limits\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\/ex208.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex208.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex208.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1936,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/382-dot-plot-with-several-variables-using-seaborn-library\/","url_meta":{"origin":1861,"position":3},"title":"#382 Dot plot with several variables using seaborn library","author":"gantovnik","date":"2023-08-10","format":false,"excerpt":"[code language=\"python\"] #Overlapping densities ridge 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(): # Load the dataset crashes = sns.load_dataset(\"car_crashes\") # Make the PairGrid g = sns.PairGrid(crashes.sort_values(\"total\", ascending=False), x_vars=crashes.columns[:-3], y_vars=[\"abbrev\"], height=10, aspect=.25) # Draw a dot plot using\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\/ex382.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex382.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex382.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex382.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex382.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1226,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2\/","url_meta":{"origin":1861,"position":4},"title":"#218 Polar plot","author":"gantovnik","date":"2021-11-28","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt r = np.arange(0, 2, 0.01) theta = 2 * np.pi * r fig, ax = plt.subplots(subplot_kw={'projection': 'polar'}) ax.plot(theta, r) ax.set_rmax(2) ax.set_rticks([0.5, 1, 1.5, 2]) # Less radial ticks ax.set_rlabel_position(-22.5) # Move radial labels away from plotted line ax.grid(True) ax.set_title(\"A line\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\/ex218.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1912,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/372-tsa-data-number-of-passengers-at-usa-airport-checkpoints\/","url_meta":{"origin":1861,"position":5},"title":"#372 TSA data: Number of passengers at USA airport checkpoints","author":"gantovnik","date":"2023-08-09","format":false,"excerpt":"Good news for the aerospace industry because the number of passengers passing through TSA checkpoints this year is the same as in 2019 (before COVID-19). [code language=\"python\"] import pandas as pd import numpy as np import math import matplotlib.pyplot as plt from plotnine import ggplot, geom_point, aes, stat_smooth, facet_wrap,geom_smooth,labs, scale_x_continuous,geom_line\u2026","rel":"","context":"In &quot;aerospace&quot;","block_context":{"text":"aerospace","link":"https:\/\/gantovnik.com\/bio-tips\/category\/aerospace\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/tsa_2023_08.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/tsa_2023_08.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/tsa_2023_08.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/tsa_2023_08.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/tsa_2023_08.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/tsa_2023_08.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1861","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=1861"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1861\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}