<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Data Visualization Archives - Be on the Right Side of Change</title>
	<atom:link href="https://blog.finxter.com/category/data-visualization/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.finxter.com/category/data-visualization/</link>
	<description></description>
	<lastBuildDate>Sun, 31 Mar 2024 07:21:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.finxter.com/wp-content/uploads/2020/08/cropped-cropped-finxter_nobackground-32x32.png</url>
	<title>Data Visualization Archives - Be on the Right Side of Change</title>
	<link>https://blog.finxter.com/category/data-visualization/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Fit a Curve to Power-law Distributed Data in Python</title>
		<link>https://blog.finxter.com/fitting-a-curve-to-power-law-distributed-data-a-python-tutorial/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Sun, 31 Mar 2024 07:21:01 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[NumPy]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SciPy]]></category>
		<category><![CDATA[Statistics]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1669961</guid>

					<description><![CDATA[<p>In this tutorial, you&#8217;ll learn how to generate synthetic data that follows a power-law distribution, plot its cumulative distribution function (CDF), and fit a power-law curve to this CDF using Python. This process is useful for analyzing datasets that follow power-law distributions, which are common in natural and social phenomena. Prerequisites Ensure you have Python ... <a title="How to Fit a Curve to Power-law Distributed Data in Python" class="read-more" href="https://blog.finxter.com/fitting-a-curve-to-power-law-distributed-data-a-python-tutorial/" aria-label="Read more about How to Fit a Curve to Power-law Distributed Data in Python">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/fitting-a-curve-to-power-law-distributed-data-a-python-tutorial/">How to Fit a Curve to Power-law Distributed Data in Python</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this tutorial, you&#8217;ll learn how to generate synthetic data that follows a power-law distribution, plot its cumulative distribution function (CDF), and fit a power-law curve to this CDF using Python. This process is useful for analyzing datasets that follow power-law distributions, which are common in natural and social phenomena.</p>



<h2 class="wp-block-heading">Prerequisites</h2>



<p>Ensure you have Python installed, along with the <code>numpy</code>, <code>matplotlib</code>, and <code>scipy</code> libraries. If not, you can install them using pip:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install numpy matplotlib scipy</pre>



<h2 class="wp-block-heading">Step 1: Generate Power-law Distributed Data</h2>



<p>First, we&#8217;ll generate a dataset that follows a power-law distribution using <code>numpy</code>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import numpy as np

# Parameters
alpha = 3.0  # Exponent of the distribution
size = 1000  # Number of data points

# Generate power-law distributed data
data = np.random.power(a=alpha, size=size)</pre>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/how-to-generate-and-plot-random-samples-from-a-power-law-distribution-in-python/">How to Generate and Plot Random Samples from a Power-Law Distribution in Python?</a></p>



<p>The data looks like this:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="921" height="594" src="https://blog.finxter.com/wp-content/uploads/2024/03/image-58.png" alt="" class="wp-image-1669962" srcset="https://blog.finxter.com/wp-content/uploads/2024/03/image-58.png 921w, https://blog.finxter.com/wp-content/uploads/2024/03/image-58-300x193.png 300w, https://blog.finxter.com/wp-content/uploads/2024/03/image-58-768x495.png 768w" sizes="(max-width: 921px) 100vw, 921px" /></figure>
</div>


<p>Let&#8217;s make some sense out of it and plot it in 2D space: <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4c8.png" alt="📈" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>



<h2 class="wp-block-heading">Step 2: Plot the Cumulative Distribution Function (CDF)</h2>



<p>Next, we&#8217;ll plot the CDF of the generated data on a log-log scale to visualize its power-law distribution.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt

# Prepare data for the CDF plot
sorted_data = np.sort(data)
yvals = np.arange(1, len(sorted_data) + 1) / float(len(sorted_data))

# Plot the CDF
plt.plot(sorted_data, yvals, marker='.', linestyle='none', color='blue')
plt.xlabel('Value')
plt.ylabel('Cumulative Frequency')
plt.title('CDF of Power-law Distributed Data')
plt.xscale('log')
plt.yscale('log')
plt.grid(True, which="both", ls="--")
plt.show()</pre>



<p>The plot:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="578" height="459" src="https://blog.finxter.com/wp-content/uploads/2024/03/Untitled-5.png" alt="" class="wp-image-1669964" srcset="https://blog.finxter.com/wp-content/uploads/2024/03/Untitled-5.png 578w, https://blog.finxter.com/wp-content/uploads/2024/03/Untitled-5-300x238.png 300w" sizes="(max-width: 578px) 100vw, 578px" /></figure>
</div>


<h2 class="wp-block-heading">Step 3: Fit a Power-law Curve to the CDF</h2>



<p>To understand the underlying power-law distribution better, we fit a curve to the CDF using the <code>curve_fit</code> function from <code>scipy.optimize</code>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from scipy.optimize import curve_fit

# Power-law fitting function
def power_law_fit(x, a, b):
    return a * np.power(x, b)

# Fit the power-law curve
params, covariance = curve_fit(power_law_fit, sorted_data, yvals)

# Generate fitted values
fitted_yvals = power_law_fit(sorted_data, *params)</pre>



<h2 class="wp-block-heading">Step 4: Plot the Fitted Curve with the CDF</h2>



<p>Finally, we&#8217;ll overlay the fitted power-law curve on the original CDF plot to visually assess the fit.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Plot the original CDF and the fitted power-law curve
plt.plot(sorted_data, yvals, marker='.', linestyle='none', color='blue', label='Original Data')
plt.plot(sorted_data, fitted_yvals, 'r-', label='Fitted Power-law Curve')
plt.xlabel('Value')
plt.ylabel('Cumulative Frequency')
plt.title('CDF with Fitted Power-law Curve')
plt.xscale('log')
plt.yscale('log')
plt.grid(True, which="both", ls="--")
plt.legend()
plt.show()</pre>



<p>Voilà! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="578" height="459" src="https://blog.finxter.com/wp-content/uploads/2024/03/Untitled-6.png" alt="" class="wp-image-1669965" srcset="https://blog.finxter.com/wp-content/uploads/2024/03/Untitled-6.png 578w, https://blog.finxter.com/wp-content/uploads/2024/03/Untitled-6-300x238.png 300w" sizes="(max-width: 578px) 100vw, 578px" /></figure>
</div>


<p>This visualization helps in assessing the accuracy of the power-law model in describing the distribution of the data. </p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>Recommended article: </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="664" src="https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1536x996-1-1024x664.png" alt="" class="wp-image-1669966" srcset="https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1536x996-1-1024x664.png 1024w, https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1536x996-1-300x195.png 300w, https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1536x996-1-768x498.png 768w, https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1536x996-1.png 1536w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/visualizing-wealth-plotting-the-net-worth-of-the-worlds-richest-in-log-log-space/">Visualizing Wealth: Plotting the Net Worth of the World’s Richest in Log/Log Space</a></p>
<p>The post <a href="https://blog.finxter.com/fitting-a-curve-to-power-law-distributed-data-a-python-tutorial/">How to Fit a Curve to Power-law Distributed Data in Python</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Visualizing Wealth: Plotting the Net Worth of the World&#8217;s Richest in Log/Log Space</title>
		<link>https://blog.finxter.com/visualizing-wealth-plotting-the-net-worth-of-the-worlds-richest-in-log-log-space/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Mon, 25 Mar 2024 11:30:48 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Matplotlib]]></category>
		<category><![CDATA[NumPy]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1669872</guid>

					<description><![CDATA[<p>The distribution of wealth, especially when it comes to the ultra-wealthy, is a subject of immense fascination and study. It can reveal patterns and insights into economic structures, inequality, and financial dynamics at the highest levels. One of the most revealing ways to examine this distribution is through a log/log plot of the net worths ... <a title="Visualizing Wealth: Plotting the Net Worth of the World&#8217;s Richest in Log/Log Space" class="read-more" href="https://blog.finxter.com/visualizing-wealth-plotting-the-net-worth-of-the-worlds-richest-in-log-log-space/" aria-label="Read more about Visualizing Wealth: Plotting the Net Worth of the World&#8217;s Richest in Log/Log Space">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/visualizing-wealth-plotting-the-net-worth-of-the-worlds-richest-in-log-log-space/">Visualizing Wealth: Plotting the Net Worth of the World&#8217;s Richest in Log/Log Space</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>The distribution of wealth, especially when it comes to the ultra-wealthy, is a subject of immense fascination and study. It can reveal patterns and insights into economic structures, inequality, and financial dynamics at the highest levels.</p>



<p>One of the most revealing ways to examine this distribution is through a <strong>log/log plot of the net worths of the world&#8217;s richest individuals</strong>. Here&#8217;s how to visualize the net worth of the top 100 richest people using Python, providing a step-by-step guide to create a log/log space plot.</p>



<h2 class="wp-block-heading">Understanding the Data</h2>



<p class="has-global-color-8-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4b0.png" alt="💰" class="wp-smiley" style="height: 1em; max-height: 1em;" /> The <a href="https://www.businessinsider.in/thelife/personalities/news/top-100-richest-people-in-the-world-some-interesting-facts/articleshow/91069161.cms" target="_blank" rel="noreferrer noopener">dataset</a> consists of the net worths of the top 100 richest people in the world. This information is often available from financial news outlets and wealth-tracking websites. For the purpose of this demonstration, assume we have this data in a list where each value represents an individual&#8217;s net worth in billions of dollars.</p>



<p>Here&#8217;s a sample from the data: </p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="701" height="748" src="https://blog.finxter.com/wp-content/uploads/2024/03/image-31.png" alt="" class="wp-image-1669874" srcset="https://blog.finxter.com/wp-content/uploads/2024/03/image-31.png 701w, https://blog.finxter.com/wp-content/uploads/2024/03/image-31-281x300.png 281w" sizes="auto, (max-width: 701px) 100vw, 701px" /></figure>
</div>


<h2 class="wp-block-heading">Why Log/Log Space?</h2>



<p>A log/log plot is particularly useful for data that spans several orders of magnitude, as it does with the world&#8217;s wealthiest individuals. This type of plot can help to linearize exponential relationships, making it easier to identify patterns that might not be apparent in a linear plot. For wealth distributions, which often follow a power law, log/log plots can highlight the underlying distribution&#8217;s scale-free nature.</p>



<h2 class="wp-block-heading">Preparing for the Plot</h2>



<p>Before plotting, ensure you have Python installed on your system along with the necessary libraries: Matplotlib for plotting and NumPy for numerical operations.</p>



<p>If you haven&#8217;t already, you can install these libraries using pip:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install matplotlib numpy</pre>



<h2 class="wp-block-heading">The Python Script</h2>



<p>First, import the necessary libraries:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt
import numpy as np</pre>



<p>Assuming you have the net worth data in a list named <code>net_worths</code> in billions of dollars, you can prepare your data. </p>



<p>For ease of reproducibility, I&#8217;ll include my list at the point of writing here: </p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">net_worths_float = [
    234.0, 156.0, 155.0, 126.0, 125.0, 124.0, 118.0, 117.0, 116.0, 116.0,
    87.8, 84.6, 82.4, 74.3, 72.6, 70.6, 69.6, 67.8, 63.2, 61.7, 61.6, 59.4,
    50.5, 50.5, 42.3, 41.3, 41.3, 40.0, 39.9, 39.1, 38.8, 37.0, 36.1, 36.0,
    35.2, 35.1, 34.2, 32.9, 32.0, 31.9, 31.9, 31.5, 30.1, 29.5, 29.3, 29.2,
    28.9, 28.5, 28.0, 27.9, 27.9, 27.7, 27.3, 27.1, 26.6, 26.5, 26.5, 25.9,
    25.1, 23.9, 23.9, 23.4, 23.2, 23.2, 23.0, 22.6, 22.3, 22.1, 21.8, 21.6,
    21.5, 21.5, 21.4, 21.4, 21.3, 21.2, 20.6, 20.6, 20.4, 20.3, 19.9, 19.7,
    19.6, 19.1, 19.0, 18.9, 18.8, 18.8, 18.5, 18.5, 18.5, 18.5, 18.4, 17.7,
    17.6, 17.6, 17.5, 17.2, 17.2, 17.2
]</pre>



<p>If your data isn&#8217;t sorted, sort it in descending order:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">net_worths = sorted(net_worths, reverse=True)</pre>



<p>Next, create a rank for each individual based on their position in the <a href="https://blog.finxter.com/5-best-ways-to-sort-lists-in-python-by-a-particular-digit-count-in-elements/" data-type="post" data-id="1663918">sorted list</a>. The richest person gets rank 1, the second richest gets rank 2, and so on:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">ranks = np.arange(1, len(net_worths) + 1)</pre>



<h2 class="wp-block-heading">Plotting the Data</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="664" src="https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1-1024x664.png" alt="" class="wp-image-1669875" srcset="https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1-1024x664.png 1024w, https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1-300x195.png 300w, https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1-768x498.png 768w, https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1-1536x996.png 1536w, https://blog.finxter.com/wp-content/uploads/2024/03/8a9b7881-bc2d-4100-80df-5da295e73602-1.png 1701w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Now, you&#8217;re ready to plot the data in log/log space:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="2" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">plt.figure(figsize=(10, 6))
plt.loglog(ranks, net_worths, marker='o', linestyle='-', color='b')
plt.xlabel('Rank (log scale)')
plt.ylabel('Net Worth in Billions (log scale)')
plt.title('Net Worth of the Top 100 Richest People (Log/Log Space)')
plt.grid(True, which="both", ls="--")
plt.show()</pre>



<p></p>



<p>This code snippet will generate a log/log plot of the net worths. The <code>loglog</code> function from Matplotlib is used to automatically scale both axes to a logarithmic scale. Markers are added for each point to clearly delineate the individual net worths, and a grid is added for better readability.</p>



<h2 class="wp-block-heading">Interpreting the Plot</h2>



<p class="has-global-color-8-background-color has-background">In the resulting plot, each point represents an individual&#8217;s net worth plotted against their rank. A straight line in a log/log plot indicates a power law distribution, common in wealth distributions and many natural phenomena. The slope of this line (if it appears roughly straight) can give you the power law&#8217;s exponent, offering deeper insights into the inequality of wealth distribution.</p>



<p>This visualization technique is not just limited to financial data; it can be applied to any dataset that spans multiple orders of magnitude and is suspected to follow a power law or similar distribution. Whether you&#8217;re a data scientist, economist, or simply a curious observer, plotting data in log/log space can unveil patterns and relationships that are not immediately visible in traditional linear plots.</p>



<h2 class="wp-block-heading">Follow Up Analysis</h2>



<p>For instance, you can examine the cumulative net worth as people are sampled from this distribution: </p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="652" src="https://blog.finxter.com/wp-content/uploads/2024/03/c4392eaa-f54f-4b24-b663-0d1364647d84-1024x652.png" alt="" class="wp-image-1669876" srcset="https://blog.finxter.com/wp-content/uploads/2024/03/c4392eaa-f54f-4b24-b663-0d1364647d84-1024x652.png 1024w, https://blog.finxter.com/wp-content/uploads/2024/03/c4392eaa-f54f-4b24-b663-0d1364647d84-300x191.png 300w, https://blog.finxter.com/wp-content/uploads/2024/03/c4392eaa-f54f-4b24-b663-0d1364647d84-768x489.png 768w, https://blog.finxter.com/wp-content/uploads/2024/03/c4392eaa-f54f-4b24-b663-0d1364647d84-1536x979.png 1536w, https://blog.finxter.com/wp-content/uploads/2024/03/c4392eaa-f54f-4b24-b663-0d1364647d84.png 1728w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Also, check out our Finxter article:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://blog.finxter.com/8-millionaire-tips-to-reach-financial-freedom-as-a-coder/"><img loading="lazy" decoding="async" width="952" height="632" src="https://blog.finxter.com/wp-content/uploads/2024/03/image-92.png" alt="" class="wp-image-1669878" srcset="https://blog.finxter.com/wp-content/uploads/2024/03/image-92.png 952w, https://blog.finxter.com/wp-content/uploads/2024/03/image-92-300x199.png 300w, https://blog.finxter.com/wp-content/uploads/2024/03/image-92-768x510.png 768w" sizes="auto, (max-width: 952px) 100vw, 952px" /></a></figure>
</div>


<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/8-millionaire-tips-to-reach-financial-freedom-as-a-coder/">8 Millionaire Tips to Reach Financial Freedom as a Coder</a></p>
<p>The post <a href="https://blog.finxter.com/visualizing-wealth-plotting-the-net-worth-of-the-worlds-richest-in-log-log-space/">Visualizing Wealth: Plotting the Net Worth of the World&#8217;s Richest in Log/Log Space</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>The Art of Clean Code &#8211; Less Is More In Design</title>
		<link>https://blog.finxter.com/the-art-of-clean-code-less-is-more-in-design/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Tue, 16 Jan 2024 14:41:52 +0000</pubDate>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Web Development]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1654234</guid>

					<description><![CDATA[<p>As developers, we rarely perceive ourselves as designers, yet interface crafting is an integral facet of our craft. Be it shaping an intuitive dashboard for data analysis, architecting an easily navigable API, or constructing straightforward web interfaces for blockchain applications, a grasp on basic design principles separates the forgettable from the functional. 💡 This chapter ... <a title="The Art of Clean Code &#8211; Less Is More In Design" class="read-more" href="https://blog.finxter.com/the-art-of-clean-code-less-is-more-in-design/" aria-label="Read more about The Art of Clean Code &#8211; Less Is More In Design">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/the-art-of-clean-code-less-is-more-in-design/">The Art of Clean Code &#8211; Less Is More In Design</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>As developers, we rarely perceive ourselves as designers, yet interface crafting is an integral facet of our craft. </p>



<p>Be it shaping an intuitive dashboard for data analysis, architecting an easily navigable API, or constructing straightforward web interfaces for blockchain applications, a grasp on basic design principles separates the forgettable from the functional. </p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> This chapter examines the impactful principle of minimalism in design and user experience (UX).</p>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Previous Chapter</strong>: <a href="https://blog.finxter.com/the-unix-philosophy/" data-type="link" data-id="https://blog.finxter.com/the-unix-philosophy/">The Art of Clean Code — 14 Unix Principles</a></p>



<h2 class="wp-block-heading">Transformative Minimalism in Tech&#8217;s Evolution</h2>



<p>Reflect on the mobile phone&#8217;s trajectory—from the cumbersome &#8217;80s bulk to the sleek smartphones of the 21st century. Through Nokia&#8217;s iterative shedding of weight and size, and the eventual rise of the iPhone, a pattern emerges: elegance in tech aligns with the pursuit of less.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="604" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-103.png" alt="" class="wp-image-1654235" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-103.png 604w, https://blog.finxter.com/wp-content/uploads/2024/01/image-103-300x169.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /><figcaption class="wp-element-caption">Milestones in the evolution of mobile phones</figcaption></figure>
</div>


<p>This narrative is not exclusive to phones. Google&#8217;s search homepage offers a masterclass in minimalism—billions of users are welcomed daily by simplicity incarnate. </p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="605" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-104.png" alt="" class="wp-image-1654236" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-104.png 605w, https://blog.finxter.com/wp-content/uploads/2024/01/image-104-300x169.png 300w" sizes="auto, (max-width: 605px) 100vw, 605px" /></figure>
</div>


<p>In stark contrast, competitors like Yahoo muddied their interfaces with ads and news, a move that cost them users and market dominance.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="604" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-105.png" alt="" class="wp-image-1654237" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-105.png 604w, https://blog.finxter.com/wp-content/uploads/2024/01/image-105-300x169.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /></figure>
</div>


<p>Google&#8217;s <a href="https://material.io/design" data-type="link" data-id="https://material.io/design">Material Design</a> philosophies reinforce this commitment to intuitive, minimalist interfaces that resonate with users through familiarity and ease of interaction. These design choices aren&#8217;t solely about aesthetics; they are strategic, optimizing the most valuable resources: </p>



<ul class="wp-block-list">
<li>user time, </li>



<li>interface space, and </li>



<li>financial investment.</li>
</ul>



<h2 class="wp-block-heading">Crafting Minimalistic Design: Principles and Practices</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="604" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-106.png" alt="" class="wp-image-1654238" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-106.png 604w, https://blog.finxter.com/wp-content/uploads/2024/01/image-106-300x169.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /><figcaption class="wp-element-caption">Material vs Non-Material Design</figcaption></figure>
</div>


<h3 class="wp-block-heading">Prioritizing Whitespace</h3>



<p>Whitespace may wrongly be deemed wasted space—when it&#8217;s quite the contrary. Google and Apple leverage it to maintain user focus and clarity. An uncluttered interface may be the divider between retaining users and losing them to confusion.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="604" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-107.png" alt="" class="wp-image-1654239" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-107.png 604w, https://blog.finxter.com/wp-content/uploads/2024/01/image-107-300x169.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /></figure>
</div>


<p>The figure shows a simple design idea for an <strong>online pizza delivery service</strong>. The whitespace supports the focus on the main thing: getting customers to order pizza. Unfortunately, seldomly will a pizza delivery service be bold enough to use whitespace in such an extreme way.</p>



<p>Whitespace also helps increasing clarity with text:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="604" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-108.png" alt="" class="wp-image-1654240" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-108.png 604w, https://blog.finxter.com/wp-content/uploads/2024/01/image-108-300x169.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /></figure>
</div>


<p>The left side of the figure is far less readable. </p>



<p>The right side injects whitespace to improve readability and UX: </p>



<ul class="wp-block-list">
<li>margins on the left and right around the text block, </li>



<li>indentation of paragraphs, </li>



<li>an increased line height, </li>



<li>top and bottom margins around paragraphs, and </li>



<li>increased font size. </li>
</ul>



<p>The costs of this additional space are negligible: scrolling is cheap, and we don’t have to physically cut more trees for paper when the publication is digital. </p>



<p>On the other hand, the benefits are very real: the UX of your website or application improves significantly!</p>



<h3 class="wp-block-heading">Eliminating Redundant Elements</h3>



<p>In the quest for simplicity, question every element&#8217;s utility. Discard the superfluous, maintain the essential. The goal is not just good design; it is great design, one that prioritizes user needs over decorative features.</p>



<p>Here&#8217;s how you can think about it:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="604" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-109.png" alt="" class="wp-image-1654241" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-109.png 604w, https://blog.finxter.com/wp-content/uploads/2024/01/image-109-300x169.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /></figure>
</div>


<p>This shows an <strong>idealized editing process</strong> in which you classify each element according to its importance regarding the UX. </p>



<p>For example, does a menu item referring to your company’s blog help the user in the checkout process when ordering a product? No, so it should be classified as <em>not important</em>. </p>



<p>Amazon has stripped all unnecessary design elements from the ordering process, for instance, by introducing the one-click buy button. </p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9d1-200d-1f4bb.png" alt="🧑‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Story</strong>: When I first learned about this method in a scientific writing workshop, it completely transformed the way I thought about editing. Removing unimportant and less important design elements guarantees improved usability with little risk. But only truly great designers have the boldness to remove important design elements and leave only very important elements. Yet, this is what separates great from merely good design.</p>



<p>Here&#8217;s another example where many design elements have been successfully removed to accomplish greater quality and superior design:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="604" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-110.png" alt="" class="wp-image-1654242" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-110.png 604w, https://blog.finxter.com/wp-content/uploads/2024/01/image-110-300x169.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /><figcaption class="wp-element-caption"><strong>Remove unimportant elements</strong>. Left: Unfocused order page with many design elements. Right: Focused order page with unnecessary design elements removed.</figcaption></figure>
</div>


<h3 class="wp-block-heading">Cutting Down on Features</h3>



<p>Just as an author must kill their darlings, a developer must curb feature creep. The success stories of tech—think of Microsoft&#8217;s apparent bloated offerings—are actually narratives of ruthless feature prioritization.</p>



<p>But you don&#8217;t see the features that have been removed or not pursued further. To keep learning about this, check out our lesson on MVPs:</p>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/the-art-of-clean-code-minimum-viable-product-mvp/" data-type="link" data-id="https://blog.finxter.com/the-art-of-clean-code-minimum-viable-product-mvp/">The Art of Clean Code – Minimum Viable Product (MVP)</a></p>



<h3 class="wp-block-heading">Streamlining Design Variations</h3>



<p>Cognitive ease should guide design choices. Limit font variations, color uses, and sizes to reduce complexity. Consistent, focused use of these elements leads to a more coherent user experience.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="604" height="340" src="https://blog.finxter.com/wp-content/uploads/2024/01/image-111.png" alt="" class="wp-image-1654243" srcset="https://blog.finxter.com/wp-content/uploads/2024/01/image-111.png 604w, https://blog.finxter.com/wp-content/uploads/2024/01/image-111-300x169.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /></figure>
</div>


<h3 class="wp-block-heading">Consistency Across Interfaces</h3>



<p>Uniformity across app interfaces isn&#8217;t merely about aesthetics—it&#8217;s about creating a cohesive and instantly recognizable user experience. Adherence to brand guidelines ensures this consistency.</p>



<h2 class="wp-block-heading">The Future of Design: Simplicity Reigns</h2>



<p>As we look ahead, the essence of minimalism in design seems poised to deepen with advancements in voice recognition and virtual interfaces.</p>



<p>The trend suggests an evolution toward even more streamlined user experiences. We&#8217;re moving towards an era where the ultimate design may well be an &#8216;invisible&#8217; interface, integrated seamlessly into our daily lives.</p>



<p>Through examples from giants like Apple and Google, we&#8217;ve observed the powerful impact minimalism has in the tech world—a realm where the simplest interfaces are often the most successful. As technology continues to evolve, one truth remains clear: <strong>in the world of design, less indeed proves to be more</strong>.</p>



<p>Stay tuned for the next chapter, where we conclude with focus—its critical role and impact in the realm of programming.</p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Advanced Reading</strong>: For those eager to delve into the principles highlighted in this chapter, detailed insights can be found in Google&#8217;s Material Design guidelines (<a href="https://material.io/design/introduction/">https://material.io/design/introduction/</a>) and Apple&#8217;s Interface design documentation (<a href="https://developer.apple.com/design/human-interface-guidelines/">https://developer.apple.com/design/human-interface-guidelines/</a>). </p>
<p>The post <a href="https://blog.finxter.com/the-art-of-clean-code-less-is-more-in-design/">The Art of Clean Code &#8211; Less Is More In Design</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>50 Best Midjourney Style Prompts (New Version 6)</title>
		<link>https://blog.finxter.com/50-best-midjourney-style-prompts-new-version-6/</link>
		
		<dc:creator><![CDATA[Mala]]></dc:creator>
		<pubDate>Sat, 30 Dec 2023 17:03:44 +0000</pubDate>
				<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Large Language Model (LLM)]]></category>
		<category><![CDATA[Midjourney]]></category>
		<category><![CDATA[Prompt Engineering]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1653817</guid>

					<description><![CDATA[<p>👉 Please find a comma-separated list of styles at the end of this article! On Twitter, you often read beginners voicing a strong and mostly unfounded opinion that prompt engineering is not a real skill. Yet &#8211; changing a single word in a 32-word prompt can completely change the output. Alien technology, indeed! And taming ... <a title="50 Best Midjourney Style Prompts (New Version 6)" class="read-more" href="https://blog.finxter.com/50-best-midjourney-style-prompts-new-version-6/" aria-label="Read more about 50 Best Midjourney Style Prompts (New Version 6)">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/50-best-midjourney-style-prompts-new-version-6/">50 Best Midjourney Style Prompts (New Version 6)</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-global-color-8-background-color has-background"><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <em>Please find a comma-separated list of styles at the end of this article!</em></strong></p>



<p>On Twitter, you often read beginners voicing a strong and mostly unfounded opinion that <em>prompt engineering is not a real skill</em>. Yet &#8211; changing a single word in a 32-word prompt can completely change the output. </p>



<p><a href="https://blog.finxter.com/alien-technology-catching-up-on-llms-prompting-chatgpt-plugins-embeddings-code-interpreter/" data-type="post" data-id="1553158">Alien technology</a>, indeed! And taming this technology is what <a href="https://blog.finxter.com/prompt-engineering-with-llama-2-full-course/" data-type="post" data-id="1651865">prompt engineering</a> is all about. </p>



<p>In this article, I&#8217;ll give you the image outputs when using the following prompt on <a href="https://blog.finxter.com/midjourney-v5-vs-v6/" data-type="post" data-id="1653772">Midjourney&#8217;s new version 6</a>, changing only a single word at the end: <strong>the style specifier</strong>.</p>



<pre class="wp-block-preformatted"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4ac.png" alt="💬" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Midjourney V6 Prompt</strong>: <code>A young woman with straight, dark-blonde hair and mocha-colored doe eyes. She has a V-shaped face and a slightly curved nose. She sits on a hill, reading a book. <mark><b>[style_specifier_here</b>]</mark></code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-11.jpg" alt="" class="wp-image-1653818" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-11.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-11-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-11-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<p>The image above is produced by the <strong><em>vanilla prompt</em></strong>, i.e., without a style specifier. Now let&#8217;s have a look at the different style specifiers you can use in your own image prompts:</p>



<h2 class="wp-block-heading">Minecraft</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-24-1024x1024.jpg" alt="" class="wp-image-1653847" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-24-1024x1024.jpg 1024w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-24-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-24-150x150.jpg 150w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-24-768x768.jpg 768w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-24-1536x1536.jpg 1536w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-24.jpg 1600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h2 class="wp-block-heading">Lego</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-26.jpg" alt="" class="wp-image-1653848" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-26.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-26-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-26-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<p> </p>



<h2 class="wp-block-heading">Hyperrealism</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-10.jpg" alt="" class="wp-image-1653819" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-10.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-10-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-10-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Realism</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-12.jpg" alt="" class="wp-image-1653820" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-12.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-12-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-12-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Impressionism</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-11.jpg" alt="" class="wp-image-1653821" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-11.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-11-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-11-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Illustration</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-13.jpg" alt="" class="wp-image-1653822" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-13.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-13-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-13-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Watercolor</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-12.jpg" alt="" class="wp-image-1653823" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-12.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-12-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-12-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Stained Glass Window</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-14.jpg" alt="" class="wp-image-1653824" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-14.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-14-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-14-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Oil Painting</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-13.jpg" alt="" class="wp-image-1653825" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-13.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-13-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-13-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Steampunk</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-15.jpg" alt="" class="wp-image-1653826" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-15.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-15-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-15-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Anime</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-14.jpg" alt="" class="wp-image-1653827" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-14.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-14-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-14-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Art-deco</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-16.jpg" alt="" class="wp-image-1653828" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-16.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-16-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-16-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Abstract Expressionism</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-15.jpg" alt="" class="wp-image-1653829" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-15.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-15-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-15-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Gothic</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-17.jpg" alt="" class="wp-image-1653830" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-17.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-17-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-17-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Pop-art</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-16.jpg" alt="" class="wp-image-1653831" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-16.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-16-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-16-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Glitch art</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-18.jpg" alt="" class="wp-image-1653832" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-18.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-18-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-18-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Cartoon</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-17.jpg" alt="" class="wp-image-1653833" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-17.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-17-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-17-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Paper cut art</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-19.jpg" alt="" class="wp-image-1653834" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-19.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-19-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-19-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Dripping painting</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-18.jpg" alt="" class="wp-image-1653835" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-18.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-18-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-18-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Renaissance</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-20.jpg" alt="" class="wp-image-1653836" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-20.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-20-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-20-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Graffity</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-19.jpg" alt="" class="wp-image-1653837" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-19.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-19-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-19-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Mosaic</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-21.jpg" alt="" class="wp-image-1653838" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-21.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-21-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-21-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Minimalistic</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-20.jpg" alt="" class="wp-image-1653839" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-20.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-20-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-20-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Art Nouveau</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-22.jpg" alt="" class="wp-image-1653840" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-22.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-22-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-22-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Geometric</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-21.jpg" alt="" class="wp-image-1653841" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-21.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-21-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-21-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Classicism</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-23.jpg" alt="" class="wp-image-1653842" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-23.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-23-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-23-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Baroque</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-22.jpg" alt="" class="wp-image-1653843" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-22.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-22-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-22-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Ukiyo-E</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-24.jpg" alt="" class="wp-image-1653844" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-24.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-24-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-24-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Statue</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-23-1024x1024.jpg" alt="" class="wp-image-1653845" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-23-1024x1024.jpg 1024w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-23-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-23-150x150.jpg 150w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-23-768x768.jpg 768w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-23-1536x1536.jpg 1536w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-23.jpg 1600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h2 class="wp-block-heading">Chalk drawing</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-25.jpg" alt="" class="wp-image-1653846" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-25.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-25-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-25-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Street art</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-27-1024x1024.jpg" alt="" class="wp-image-1653849" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-27-1024x1024.jpg 1024w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-27-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-27-150x150.jpg 150w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-27-768x768.jpg 768w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-27-1536x1536.jpg 1536w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-27.jpg 1600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h2 class="wp-block-heading">Pencil drawing</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-25.jpg" alt="" class="wp-image-1653850" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-25.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-25-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-1-25-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Harry Potter style</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="593" src="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-28.jpg" alt="" class="wp-image-1653851" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-28.jpg 593w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-28-300x300.jpg 300w, https://blog.finxter.com/wp-content/uploads/2023/12/Untitled-28-150x150.jpg 150w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure>
</div>


<h2 class="wp-block-heading">Futurist</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4adff28a-818a-463e-9441-3d22952ff165-1.webp" alt="" class="wp-image-1653861" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4adff28a-818a-463e-9441-3d22952ff165-1.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4adff28a-818a-463e-9441-3d22952ff165-1-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4adff28a-818a-463e-9441-3d22952ff165-1-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4adff28a-818a-463e-9441-3d22952ff165-1-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Picasso</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7ee65f72-5feb-497a-8d83-ce3b13f285d3.webp" alt="" class="wp-image-1653853" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7ee65f72-5feb-497a-8d83-ce3b13f285d3.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7ee65f72-5feb-497a-8d83-ce3b13f285d3-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7ee65f72-5feb-497a-8d83-ce3b13f285d3-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7ee65f72-5feb-497a-8d83-ce3b13f285d3-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Dali</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_84dbc824-9349-411c-b31b-defd34b2ed64.webp" alt="" class="wp-image-1653854" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_84dbc824-9349-411c-b31b-defd34b2ed64.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_84dbc824-9349-411c-b31b-defd34b2ed64-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_84dbc824-9349-411c-b31b-defd34b2ed64-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_84dbc824-9349-411c-b31b-defd34b2ed64-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Pixeled</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c51288c9-5b32-4764-ae0f-cd34247994ac.webp" alt="" class="wp-image-1653855" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c51288c9-5b32-4764-ae0f-cd34247994ac.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c51288c9-5b32-4764-ae0f-cd34247994ac-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c51288c9-5b32-4764-ae0f-cd34247994ac-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c51288c9-5b32-4764-ae0f-cd34247994ac-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Monet</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7e22960f-51b3-4ce8-b8a1-cf3746fb7113-1.webp" alt="" class="wp-image-1653856" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7e22960f-51b3-4ce8-b8a1-cf3746fb7113-1.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7e22960f-51b3-4ce8-b8a1-cf3746fb7113-1-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7e22960f-51b3-4ce8-b8a1-cf3746fb7113-1-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7e22960f-51b3-4ce8-b8a1-cf3746fb7113-1-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Simpsons</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_f30a6a9b-127b-4523-ba91-330990eb3ddd.webp" alt="" class="wp-image-1653858" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_f30a6a9b-127b-4523-ba91-330990eb3ddd.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_f30a6a9b-127b-4523-ba91-330990eb3ddd-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_f30a6a9b-127b-4523-ba91-330990eb3ddd-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_f30a6a9b-127b-4523-ba91-330990eb3ddd-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Rembrandt</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_56221e74-7383-4629-92d9-6eb92f3419fa.webp" alt="" class="wp-image-1653860" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_56221e74-7383-4629-92d9-6eb92f3419fa.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_56221e74-7383-4629-92d9-6eb92f3419fa-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_56221e74-7383-4629-92d9-6eb92f3419fa-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_56221e74-7383-4629-92d9-6eb92f3419fa-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Retro 80s</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4225918a-00e1-421c-a372-f1cbbf4fdd85.webp" alt="" class="wp-image-1653862" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4225918a-00e1-421c-a372-f1cbbf4fdd85.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4225918a-00e1-421c-a372-f1cbbf4fdd85-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4225918a-00e1-421c-a372-f1cbbf4fdd85-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_4225918a-00e1-421c-a372-f1cbbf4fdd85-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Rococo</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_a6f50a13-37ae-4d88-884b-aa1776b93759.webp" alt="" class="wp-image-1653863" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_a6f50a13-37ae-4d88-884b-aa1776b93759.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_a6f50a13-37ae-4d88-884b-aa1776b93759-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_a6f50a13-37ae-4d88-884b-aa1776b93759-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_a6f50a13-37ae-4d88-884b-aa1776b93759-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Low Poly</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_1863697e-c82b-4289-be5a-613dab6622f6.webp" alt="" class="wp-image-1653864" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_1863697e-c82b-4289-be5a-613dab6622f6.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_1863697e-c82b-4289-be5a-613dab6622f6-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_1863697e-c82b-4289-be5a-613dab6622f6-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_1863697e-c82b-4289-be5a-613dab6622f6-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Manga</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_95385ed4-c270-47e3-b974-e4d86f398d3c.webp" alt="" class="wp-image-1653865" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_95385ed4-c270-47e3-b974-e4d86f398d3c.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_95385ed4-c270-47e3-b974-e4d86f398d3c-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_95385ed4-c270-47e3-b974-e4d86f398d3c-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_95385ed4-c270-47e3-b974-e4d86f398d3c-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">The Sims</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_d665af68-6115-4d7b-bb01-d78fa07c852d.webp" alt="" class="wp-image-1653866" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_d665af68-6115-4d7b-bb01-d78fa07c852d.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_d665af68-6115-4d7b-bb01-d78fa07c852d-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_d665af68-6115-4d7b-bb01-d78fa07c852d-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_d665af68-6115-4d7b-bb01-d78fa07c852d-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Bauhaus</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7dd542e7-02cc-4fec-858e-a75aad10cacc.webp" alt="" class="wp-image-1653867" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7dd542e7-02cc-4fec-858e-a75aad10cacc.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7dd542e7-02cc-4fec-858e-a75aad10cacc-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7dd542e7-02cc-4fec-858e-a75aad10cacc-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7dd542e7-02cc-4fec-858e-a75aad10cacc-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Art Informel</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c9a07a30-73c8-47c8-a7f0-45c68b7ea366.webp" alt="" class="wp-image-1653869" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c9a07a30-73c8-47c8-a7f0-45c68b7ea366.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c9a07a30-73c8-47c8-a7f0-45c68b7ea366-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c9a07a30-73c8-47c8-a7f0-45c68b7ea366-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_c9a07a30-73c8-47c8-a7f0-45c68b7ea366-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Pastel</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_231eed16-e7e4-444b-a74e-2b45d0ce8ff0.webp" alt="" class="wp-image-1653870" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_231eed16-e7e4-444b-a74e-2b45d0ce8ff0.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_231eed16-e7e4-444b-a74e-2b45d0ce8ff0-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_231eed16-e7e4-444b-a74e-2b45d0ce8ff0-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_231eed16-e7e4-444b-a74e-2b45d0ce8ff0-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">Disney</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7eb18148-d0c2-4b7c-8af0-4222e7c6cb36.webp" alt="" class="wp-image-1653875" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7eb18148-d0c2-4b7c-8af0-4222e7c6cb36.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7eb18148-d0c2-4b7c-8af0-4222e7c6cb36-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7eb18148-d0c2-4b7c-8af0-4222e7c6cb36-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_7eb18148-d0c2-4b7c-8af0-4222e7c6cb36-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>



<h2 class="wp-block-heading">Genshin Impact</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="783" height="783" src="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_3f6f0366-699c-455e-92f9-65daa552505c.webp" alt="" class="wp-image-1653871" srcset="https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_3f6f0366-699c-455e-92f9-65daa552505c.webp 783w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_3f6f0366-699c-455e-92f9-65daa552505c-300x300.webp 300w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_3f6f0366-699c-455e-92f9-65daa552505c-150x150.webp 150w, https://blog.finxter.com/wp-content/uploads/2023/12/finxter.com_A_young_woman_with_straight_dark-blonde_hair_and_mo_3f6f0366-699c-455e-92f9-65daa552505c-768x768.webp 768w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>
</div>


<h2 class="wp-block-heading">All Styles List</h2>



<p>We tried many more, but these were the best ones. I&#8217;ve compiled a comma-separated list of all style specifiers you can use here:</p>



<pre class="wp-block-preformatted"><code>Minecraft, Lego, Hyperrealism, Realism, Impressionism, Illustration, Watercolor, Stained Glass Window, Oil Painting, Steampunk, Anime, Art-deco, Abstract Expressionism, Gothic, Pop-art, Glitch art, Cartoon, Paper cut art, Dripping painting, Renaissance, Graffity, Mosaic, Minimalistic, Art Nouveau, Geometric, Classicism, Baroque, Ukiyo-E, Statue, Chalk drawing, Street art, Pencil drawing, Harry Potter style, Futurist, Picasso, Dali, Pixeled, Monet, Simpsons, Rembrandt, Retro 80s, Rococo, Low Poly, Manga, The Sims, Bauhaus, Art Informel, Pastel, Genshin Impact.</code></pre>
<p>The post <a href="https://blog.finxter.com/50-best-midjourney-style-prompts-new-version-6/">50 Best Midjourney Style Prompts (New Version 6)</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Yahoo-Fin: Fetching Historical Stock Data with Python&#8217;s Yahoo Finance API</title>
		<link>https://blog.finxter.com/yahoo-fin-fetching-historical-stock-data-with-pythons-yahoo-finance-api/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Sat, 18 Nov 2023 10:53:09 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Investment]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Trading]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1653142</guid>

					<description><![CDATA[<p>This guide provides an easy-to-understand foundation for beginners and intermediate users to leverage the Yahoo Finance API with Python for financial data analysis. Yahoo Finance API offers a wealth of financial data, from stock prices and market trends to currency exchange rates. This guide will introduce you to using the Yahoo Finance API yahoo_fin with ... <a title="Yahoo-Fin: Fetching Historical Stock Data with Python&#8217;s Yahoo Finance API" class="read-more" href="https://blog.finxter.com/yahoo-fin-fetching-historical-stock-data-with-pythons-yahoo-finance-api/" aria-label="Read more about Yahoo-Fin: Fetching Historical Stock Data with Python&#8217;s Yahoo Finance API">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/yahoo-fin-fetching-historical-stock-data-with-pythons-yahoo-finance-api/">Yahoo-Fin: Fetching Historical Stock Data with Python&#8217;s Yahoo Finance API</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This guide provides an easy-to-understand foundation for beginners and intermediate users to leverage the <strong>Yahoo Finance API with Python</strong> for financial data analysis.</p>



<p>Yahoo Finance API offers a wealth of financial data, from stock prices and market trends to currency exchange rates. This guide will introduce you to using the Yahoo Finance API <code>yahoo_fin</code> with Python, a powerful combination for financial data analysis.</p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9d1-200d-1f4bb.png" alt="🧑‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Quick Info</strong>: The Python library <code><a href="https://pypi.org/project/yahoo-fin/" data-type="link" data-id="https://pypi.org/project/yahoo-fin/">yahoo_fin</a></code> is not well maintained but works for quick, dirty, and simple access without requiring you to create an API key. It provides free access to a wide range of financial data.</p>



<h2 class="wp-block-heading">Setting Up Your Environment</h2>



<p>Before diving into the API, ensure Python is installed on your system. Python 3.x is recommended for its latest features and support.</p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9d1-200d-1f4bb.png" alt="🧑‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Recommended</strong>: <a href="https://blog.finxter.com/how-to-install-python/" data-type="post" data-id="17770">How to Install Python?</a></p>



<p>You&#8217;ll primarily need <code>yahoo_fin</code>, a Python library that simplifies accessing Yahoo Finance data. Install it using pip:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install yahoo_fin</pre>



<h2 class="wp-block-heading">Understanding the Yahoo_fin Library</h2>



<p><code>yahoo_fin</code> offers two main modules:</p>



<ul class="wp-block-list">
<li><code>stock_info</code>: For stock data.</li>



<li><code>options</code>: For options data.</li>
</ul>



<p>These modules provide functions to access various data types like historical prices, stock information, etc.</p>



<h2 class="wp-block-heading">Fetching Historical Data with Yahoo_fin</h2>



<p>The <code>get_data()</code> function from <code>stock_info</code> module is used to fetch historical price data for a given stock. Here’s how you use it:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from yahoo_fin.stock_info import get_data

# Fetch historical data for Apple
apple_data = get_data('AAPL')
print(apple_data)</pre>



<p>Output:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="916" height="767" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-93.png" alt="" class="wp-image-1653143" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-93.png 916w, https://blog.finxter.com/wp-content/uploads/2023/11/image-93-300x251.png 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-93-768x643.png 768w" sizes="auto, (max-width: 916px) 100vw, 916px" /></figure>
</div>


<p>For real-time data, use the <code>get_live_price()</code> function:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="4" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from yahoo_fin.stock_info import get_live_price

# Get the current price of Tesla stock
tesla_live_price = get_live_price('TSLA')
print(tesla_live_price)
# 234.3000030517578</pre>



<h2 class="wp-block-heading">Example: Analyzing Stock Performance</h2>



<p>Python’s data analysis libraries, like Pandas, can be used in conjunction with <code>yahoo_fin</code> to perform more complex analyses.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import pandas as pd
from yahoo_fin.stock_info import get_data

# Fetch historical data for a stock
stock_data = get_data('AAPL', start_date='01/01/2020', end_date='01/01/2021')

# Convert to a Pandas DataFrame for analysis
df = pd.DataFrame(stock_data)
print(df)</pre>



<p>Output:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="788" height="887" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-94.png" alt="" class="wp-image-1653144" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-94.png 788w, https://blog.finxter.com/wp-content/uploads/2023/11/image-94-267x300.png 267w, https://blog.finxter.com/wp-content/uploads/2023/11/image-94-768x864.png 768w" sizes="auto, (max-width: 788px) 100vw, 788px" /></figure>
</div>


<h3 class="wp-block-heading">Visualizing Data</h3>



<p>With libraries like <a href="https://blog.finxter.com/python-matplotlib-makes-conways-game-of-life-come-alive/" data-type="post" data-id="972637">Matplotlib</a> or <a href="https://blog.finxter.com/how-to-create-a-pie-chart-with-seaborn/" data-type="post" data-id="326966">Seaborn</a>, you can visualize financial data:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt

# Plotting the closing price of Apple stock
plt.figure(figsize=(10, 5))
plt.plot(df['close'], label='Apple Close Price')
plt.title('Apple Stock Close Price (2020)')
plt.xlabel('Date')
plt.ylabel('Price (USD)')
plt.legend()
plt.show()</pre>



<p>This is how this looks at the time of writing (using the <code>df</code> variable defined in the previous step):</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="926" height="803" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-95.png" alt="" class="wp-image-1653145" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-95.png 926w, https://blog.finxter.com/wp-content/uploads/2023/11/image-95-300x260.png 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-95-768x666.png 768w" sizes="auto, (max-width: 926px) 100vw, 926px" /></figure>
</div>


<p>Check out our email newsletter with free cheat sheets to keep learning and improving your skills:</p>






<p></p>
<p>The post <a href="https://blog.finxter.com/yahoo-fin-fetching-historical-stock-data-with-pythons-yahoo-finance-api/">Yahoo-Fin: Fetching Historical Stock Data with Python&#8217;s Yahoo Finance API</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Matplotlib Colors: A Comprehensive Guide for Effective Visualization</title>
		<link>https://blog.finxter.com/matplotlib-colors-a-comprehensive-guide-for-effective-visualization/</link>
		
		<dc:creator><![CDATA[Emily Rosemary Collins]]></dc:creator>
		<pubDate>Tue, 14 Nov 2023 19:58:33 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Matplotlib]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1653046</guid>

					<description><![CDATA[<p>Here&#8217;s a minimal example of using colors in Matplotlib. This example creates a simple line plot with a specified color: In this minimal code example, plt.plot(x, y, color='red') creates a line plot of x versus y, with the line color set to red. You can replace 'red' with other color names like 'blue', 'green', etc., ... <a title="Matplotlib Colors: A Comprehensive Guide for Effective Visualization" class="read-more" href="https://blog.finxter.com/matplotlib-colors-a-comprehensive-guide-for-effective-visualization/" aria-label="Read more about Matplotlib Colors: A Comprehensive Guide for Effective Visualization">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/matplotlib-colors-a-comprehensive-guide-for-effective-visualization/">Matplotlib Colors: A Comprehensive Guide for Effective Visualization</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Here&#8217;s a minimal example of using colors in Matplotlib. This example creates a simple line plot with a specified color:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt

# Data
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]

# Plotting the line with a specific color, e.g., 'red'
plt.plot(x, y, color='red')

# Displaying the plot
plt.show()
</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="587" height="439" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-80.png" alt="" class="wp-image-1653060" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-80.png 587w, https://blog.finxter.com/wp-content/uploads/2023/11/image-80-300x224.png 300w" sizes="auto, (max-width: 587px) 100vw, 587px" /></figure>
</div>


<p>In this minimal code example, <code>plt.plot(x, y, color='red')</code> creates a line plot of <code>x</code> versus <code>y</code>, with the line color set to red. You can replace <code>'red'</code> with other color names like <code>'blue'</code>, <code>'green'</code>, etc., or use color codes (e.g., <code>'#FF5733'</code> for a specific shade of orange).</p>



<p>Let&#8217;s explore Matplotlib&#8217;s amazing color functionality further! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading">Understanding Matplotlib Colors</h2>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Different Color Formats in Matplotlib Python | Matplotlib Tutorial - Part 02" width="937" height="527" src="https://www.youtube.com/embed/AfKq_-5XTPM?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<h3 class="wp-block-heading">Basic Colors in Matplotlib</h3>



<p><a href="https://blog.finxter.com/python-matplotlib-makes-conways-game-of-life-come-alive/" data-type="post" data-id="972637">Matplotlib</a> is a popular data visualization library in Python, and colors play a crucial role in making these visualizations informative and visually appealing. With the right choice of colors, you can emphasize certain aspects of your data and make your plots more interpretable. In Matplotlib, you have access to a wide range of built-in colors to work with.</p>



<p>Some of the <a href="https://matplotlib.org/stable/gallery/color/named_colors.html">basic colors</a> in Matplotlib are red, green, blue, cyan, magenta, yellow, black, and white. These colors can be specified in a variety of ways, such as by their names or using RGB and RGBA values.</p>



<p>Here are some examples of how you can define colors in Matplotlib:</p>



<ul class="wp-block-list">
<li>By name: <code>'red'</code>, <code>'blue'</code>, <code>'green'</code></li>



<li>By RGB values: <code>(0.5, 0.2, 0.8)</code></li>



<li>By RGBA values: <code>(0.5, 0.2, 0.8, 0.5)</code></li>
</ul>



<h3 class="wp-block-heading">Matplotlib Recognizes Colors</h3>



<p><a href="https://matplotlib.org/stable/users/explain/colors/colors.html">Matplotlib recognizes different formats</a> to specify colors, which provides flexibility for you when customizing your visualizations. Transparency can also be added to these colors using the alpha value of an RGBA color.</p>



<p>Here&#8217;s a brief overview of some ways to specify colors in Matplotlib:</p>



<ul class="wp-block-list">
<li><strong>Named colors</strong>: E.g., <code>'coral'</code>, <code>'seagreen'</code>, <code>'royalblue'</code>.</li>



<li><strong>Hex color codes</strong>: E.g., <code>'#FF5733'</code>, <code>'#4D5656'</code>.</li>



<li><strong>RGB tuples</strong>: E.g., <code>(0.5, 0.8, 0.4)</code>.</li>



<li><strong>RGBA tuples</strong>: E.g., <code>(0.2, 0.7, 0.9, 0.6)</code>.</li>
</ul>



<p></p>



<h2 class="wp-block-heading">Working with RGB and Hex Colours</h2>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="RGB-HexColors-Explained" width="937" height="703" src="https://www.youtube.com/embed/hhI4x6hx21s?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<h3 class="wp-block-heading">RGB to Hex Conversion</h3>



<p>When working with colors in matplotlib, you might need to convert <strong>RGB</strong> values to <strong>Hex</strong> format. RGB colors are defined by a tuple of three values corresponding to the red, green, and blue components. For example, an RGB value can be represented as (0.1, 0.2, 0.5). To convert RGB colors to Hex values, you can use the <a href="https://matplotlib.org/stable/api/_as_gen/matplotlib.colors.to_hex.html"><code>matplotlib.colors.to_hex</code></a> function. Here&#8217;s an example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.colors as mcolors

rgb_color = (0.1, 0.2, 0.5)
hex_color = mcolors.to_hex(rgb_color)
print(hex_color)
# #1a3380</pre>



<p>This code snippet will convert the RGB color <code>(0.1, 0.2, 0.5)</code> into its corresponding Hex value <code>'#1A3380'</code>.</p>



<h3 class="wp-block-heading">Specifying Colors in RGB and Hex</h3>



<p>In matplotlib, you can specify colors using both RGB and Hex values. When specifying colors as <strong>RGB</strong> or <strong>RGBA</strong> (red, green, blue, alpha) tuples, make sure to use float values in the closed interval [0, 1]. For example, you can use (0.1, 0.2, 0.5) for an RGB color or (0.1, 0.2, 0.5, 0.3) for an RGBA color with alpha transparency.</p>



<p>On the other hand, to specify colors in <strong>Hex</strong> format, use a string representing the hex RGB or RGBA value (e.g., <code>'#0f0f0f'</code> for an RGB hex color or <code>'#0f0f0f80'</code> for an RGBA hex color). The Hex string is case-insensitive.</p>



<p>Here&#8217;s a simple example of how to create a scatter plot while specifying colors in RGB and Hex formats:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt

# Example data
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

# Specifying colors in RGB and Hex
colors = [
    (0.1, 0.2, 0.5),  # RGB color
    '#FF5733',        # Hex color
    (1, 0, 0, 0.5),   # RGBA color
    '#0f0f0f80'       # RGBA Hex color
]

# Creating a scatter plot
for i, color in enumerate(colors):
    plt.scatter(x[i], y[i], color=color, label=color)

plt.legend()
plt.show()
</pre>



<p>Output:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="430" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-74-1024x430.png" alt="" class="wp-image-1653047" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-74-1024x430.png 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-74-300x126.png 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-74-768x323.png 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-74.png 1178w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h2 class="wp-block-heading">Using Named Colors and XKCD Colors</h2>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Seaborn Color Palette Basics | Using named and custom color palettes in Python seaborn" width="937" height="527" src="https://www.youtube.com/embed/2wRHBodrWuY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>In matplotlib, you have access to a wide range of <a href="https://matplotlib.org/stable/gallery/color/named_colors.html">named colors</a> and <a href="https://matplotlib.org/stable/users/explain/colors/colors.html">XKCD colors</a> to create visually appealing and informative plots.</p>



<p><strong>Named colors</strong> are predefined colors with unique names, making it convenient for you to apply them in your plots. You can use basic color names such as <code>'blue'</code>, <code>'green'</code>, <code>'red'</code>, <code>'cyan'</code>, <code>'magenta'</code>, <code>'yellow'</code>, <code>'black'</code>, and <code>'white'</code>. Matplotlib library also supports a more extensive set of named colors, allowing you to choose from over 1200+ options. To work with named colors, simply use their names as the color parameter in your plot.</p>



<p><strong>XKCD colors</strong> were introduced based on a user survey conducted by the webcomic XKCD. These colors offer an even more diverse palette, with almost 95 of the 148 X11/CSS4 color names making an appearance in the XKCD color survey. Note that the color values for the X11/CSS4 and XKCD palettes may differ, with only <code>'black'</code>, <code>'white'</code>, and <code>'cyan'</code> being identical.</p>



<p>When creating your plots, you can combine both named and XKCD colors to enhance visual appeal:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2*np.pi)
y = np.sin(x)

# Using named color
plt.plot(x, y, color='blue')

# Using XKCD color
plt.plot(x, y, color='xkcd:sea green')

plt.show()</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="592" height="459" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-75.png" alt="" class="wp-image-1653048" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-75.png 592w, https://blog.finxter.com/wp-content/uploads/2023/11/image-75-300x233.png 300w" sizes="auto, (max-width: 592px) 100vw, 592px" /></figure>
</div>


<p>Remember, when using XKCD colors, prefix the color name with <code>'xkcd:'</code>, as in <code>'xkcd:gray'</code>.</p>



<p>Explore and experiment with various <a href="https://matplotlib.org/stable/gallery/color/named_colors.html">named colors</a> and <a href="https://matplotlib.org/stable/users/explain/colors/colors.html">XKCD colors</a> in your matplotlib plots to customize them according to your needs. Choosing the right color combination not only makes your plots visually pleasing but also helps in conveying the information more effectively to your audience.</p>



<h2 class="wp-block-heading">Delving into Colormaps</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="701" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-40-1024x701.jpeg" alt="" class="wp-image-1653049" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-40-1024x701.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-40-300x205.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-40-768x525.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-40.jpeg 1216w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h3 class="wp-block-heading">Standard and Custom Colormaps</h3>



<p>In Matplotlib, you have access to a wide variety of <a href="https://matplotlib.org/stable/users/explain/colors/colormaps.html">built-in colormaps</a> that can be easily utilized for visualizing your data. Some popular colormaps include <strong>viridis</strong>, <strong>plasma</strong>, and <strong>inferno</strong>. To use a colormap, simply import the <code>matplotlib.cm</code> module as <code>cm</code> and then choose from the available colormaps.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.cm as cm
custom_colormap = cm.viridis
</pre>



<p>However, sometimes you may want to create a custom colormap that matches your specific needs. In this case, you can create your own colormap using the <code>LinearSegmentedColormap.from_list()</code> method. It requires a list of RGB tuples, defining the mixture of colors from 0 to 1.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from matplotlib.colors import LinearSegmentedColormap

colors = [(0, 0, 1), (0, 1, 1), (1, 1, 0), (1, 0, 0)]
custom_colormap = LinearSegmentedColormap.from_list("my_colormap", colors)
</pre>



<h3 class="wp-block-heading">Hot and Cold Colormaps</h3>



<p>A special subset of colormaps, known as hot and cold colormaps, are particularly useful when visualizing data with temperature-like values. These colormaps help to emphasize the contrast between low and high values in your data. Examples of hot colormaps are <strong>hot</strong>, <strong>autumn</strong>, and <strong>YlOrRd</strong>. Cold colormaps include <strong>cool</strong>, <strong>winter</strong>, and <strong>PuBu</strong>.</p>



<p>When working with <code>numpy</code> arrays (<code>np</code>), you can easily apply a colormap to your data. By first normalizing your data, you ensure that the colormap maps to the full range of values in your dataset.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap

colors = [(0, 0, 1), (0, 1, 1), (1, 1, 0), (1, 0, 0)]
custom_colormap = LinearSegmentedColormap.from_list("my_colormap", colors)

data = np.random.rand(10, 10)
norm_data = (data - data.min()) / (data.max() - data.min())

fig, ax = plt.subplots()
im = ax.imshow(norm_data, cmap=custom_colormap)
plt.colorbar(im)
plt.show()
</pre>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="430" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-76-1024x430.png" alt="" class="wp-image-1653050" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-76-1024x430.png 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-76-300x126.png 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-76-768x323.png 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-76.png 1190w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p></p>



<h2 class="wp-block-heading">Matplotlib Pyplot and Its Color Utilities</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="701" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-41-1024x701.jpeg" alt="" class="wp-image-1653051" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-41-1024x701.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-41-300x205.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-41-768x525.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-41.jpeg 1216w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h3 class="wp-block-heading">Aqua and Other Unique Colors in Pyplot</h3>



<p>Matplotlib provides a diverse selection of colors, including unique ones like <a href="https://matplotlib.org/stable/users/explain/colors/colors.html">Aqua</a>. You can easily incorporate these colors into your plots to make them more visually appealing. </p>



<p>For instance, you can set an Aqua-colored line in your plot by specifying <code>c='aqua'</code> as a keyword argument when plotting with <code>plt.plot()</code>. You&#8217;ll find that it&#8217;s simple to experiment with different colors and create visually striking charts to enhance your data visualization.</p>



<h3 class="wp-block-heading">Working with Labels and Titles</h3>



<p>Adding labels and titles is essential to provide context and improve the readability of your plots. With Matplotlib&#8217;s <code>pyplot</code> (usually imported as <code>plt</code>), you can easily add titles and labels to your plots. To set a title for your plot, use the <code>plt.title()</code> function and pass in a string that describes the main topic of the plot. For example, <code>plt.title("My Aqua-colored Line Plot")</code> will display a title at the top of the plot.</p>



<p>Use <code>plt.xlabel()</code> and <code>plt.ylabel()</code> functions to label the x-axis and y-axis respectively. Provide a string describing the quantities being plotted along each axis, and the labels will appear next to the corresponding axis.</p>



<h2 class="wp-block-heading">Color Specification Conversions in Matplotlib</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="701" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-42-1024x701.jpeg" alt="" class="wp-image-1653052" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-42-1024x701.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-42-300x205.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-42-768x525.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-42.jpeg 1216w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>In Matplotlib, you can easily convert colors between different formats using built-in functions to ensure consistent handling of colors throughout your visualizations. Here are some of the key functions for color specification conversions:</p>



<ul class="wp-block-list">
<li><strong><code>to_rgba</code></strong>: This function allows you to convert a color or sequence of colors to RGBA format. It accepts a variety of input color formats (e.g., string, RGB tuple, or RGBA tuple), and normalizes the resulting RGBA values to a range of 0 to 1.</li>



<li><strong><code>to_rgba_array</code></strong>: Like the <code>to_rgba</code> function, this one converts a set of colors to RGBA format, but it does so for an entire array of colors in a single step. This is particularly useful when you&#8217;re working with colormaps or a large collection of colors.</li>



<li><strong><code>rgb_to_hsv</code></strong>: This function allows you to convert a set of RGB colors to the hue, saturation, and value (HSV) color space. This conversion can be useful for creating custom colormaps or color functions that take advantage of the HSV representation, which can be more intuitive when dealing with color palettes.</li>
</ul>



<p>Here&#8217;s an example of using these color conversion functions in your code:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.colors as mcolors

# Convert a single color to RGBA format
color_rgba = mcolors.to_rgba('blue')

# Convert a list of colors to an RGBA array
color_list = ['red', 'green', 'blue']
color_rgba_array = mcolors.to_rgba_array(color_list)

# Convert a list of RGB colors to HSV format
rgb_colors = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
hsv_colors = mcolors.rgb_to_hsv(rgb_colors)
</pre>



<p>By understanding and utilizing these color specification conversion functions in Matplotlib, you can achieve greater control over your data visualizations and ensure that your colors are represented consistently across various color formats.</p>



<h2 class="wp-block-heading">Manipulating CSS4 and Tableau Colors</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="701" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-43-1024x701.jpeg" alt="" class="wp-image-1653053" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-43-1024x701.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-43-300x205.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-43-768x525.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-43.jpeg 1216w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h3 class="wp-block-heading">Introduction to CSS4 Colors</h3>



<p>With Matplotlib, you can tap into the power of CSS4 colors to enhance your data visualizations. CSS4 colors are a standardized set of over <a href="https://matplotlib.org/stable/gallery/color/named_colors.html">140 named colors</a> that can be used in web design, and they are also available in Matplotlib for creating vibrant and meaningful plots.</p>



<p>To use CSS4 colors, simply refer to the color by its name (case-insensitive) when specifying a color for a plot. For example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [4, 5, 6], color='darkorchid')
plt.show()
</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="592" height="449" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-77.png" alt="" class="wp-image-1653054" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-77.png 592w, https://blog.finxter.com/wp-content/uploads/2023/11/image-77-300x228.png 300w" sizes="auto, (max-width: 592px) 100vw, 592px" /></figure>
</div>


<p>This code snippet will generate a line plot with a <code>darkorchid</code> color. By exploring the <a href="https://matplotlib.org/stable/gallery/color/named_colors.html">list of named CSS4 colors</a>, you can find the perfect color for your visualization needs.</p>



<h3 class="wp-block-heading">Understanding Tableau Colors</h3>



<p>Tableau is a powerful data visualization tool that offers its own set of colors, known as the Tableau palette. The Tableau color palette is designed to be visually appealing and colorblind-friendly. In Matplotlib, you can access the Tableau colors by applying the <code>tableau-colorblind10</code> style:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt

plt.style.use('tableau-colorblind10')
</pre>



<p>Once you have applied this style, Matplotlib will use the colors from the Tableau palette automatically for your plots. If you need to access a specific color from the palette, you can create a <a href="https://docs.python.org/3/library/stdtypes.html#dict">dictionary</a> of Tableau colors using their index positions:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">tableau_colors = {
    0: '#1f77b4',
    1: '#ff7f0e',
    2: '#2ca02c',
    3: '#d62728',
    4: '#9467bd',
    5: '#8c564b',
    6: '#e377c2',
    7: '#7f7f7f',
    8: '#bcbd22',
    9: '#17becf'
}

color = tableau_colors[0]  # Access the first tableau color
</pre>



<p></p>



<h2 class="wp-block-heading">Working with Grayscale and Transparency</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="701" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-44-1024x701.jpeg" alt="" class="wp-image-1653055" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-44-1024x701.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-44-300x205.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-44-768x525.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-44.jpeg 1216w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h3 class="wp-block-heading">Grayscale in Matplotlib</h3>



<p class="has-global-color-8-background-color has-background">In Matplotlib, you can easily work with grayscale images. To display an image in grayscale, you can employ the <code><a href="https://blog.finxter.com/how-to-display-an-image-as-grayscale-in-python-matplotlib/" data-type="post" data-id="27875">imshow()</a></code> function. When reading an image using the <a href="https://blog.finxter.com/how-to-get-the-size-of-an-image-with-pil-in-python/" data-type="post" data-id="362009">PIL (Python Imaging Library)</a> library, you can convert it to grayscale with the <code>convert("L")</code> method. </p>



<p>For example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from PIL import Image
import matplotlib.pyplot as plt

image = Image.open(file).convert("L")
plt.imshow(image, cmap="gray")
plt.show()
</pre>



<p>This code snippet will display the image in grayscale using the <code>gray</code> color map.</p>



<h3 class="wp-block-heading">Transparency and Alpha Channel</h3>



<p>Transparency is another useful feature to work with in Matplotlib. The alpha channel determines the transparency level of an element. Alpha values range from 0 (completely transparent) to 1 (completely opaque).</p>



<p>You can set the alpha values for various elements, such as text, lines, or patches. For example, when creating a plot with a semi-transparent orange rectangle, you can adjust the alpha value:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.patches as patches

rect = patches.Rectangle((0.5, 0.5), 1, 1, linewidth=1, edgecolor='r', facecolor='orange', alpha=0.8)
ax.add_patch(rect)
plt.show()
</pre>



<p>In this example, the orange rectangle&#8217;s transparency is controlled by setting the <code>alpha</code> parameter to 0.8. Remember to keep your plots clear and understandable when using transparency with different elements.</p>



<h2 class="wp-block-heading">Using Matplotlib to Create Scatter Plots and Colorbars</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="701" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-45-1024x701.jpeg" alt="" class="wp-image-1653056" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-45-1024x701.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-45-300x205.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-45-768x525.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-45.jpeg 1216w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>In this section, we will discuss how you can use Matplotlib to create scatter plots and colorbars in your data visualizations. By the end of this section, you will be able to confidently create scatter plots and colorbars using the Matplotlib library.</p>



<h3 class="wp-block-heading">Creating Scatter Plots</h3>



<p>Scatter plots are widely used to visualize the relationships between two continuous data features. With Matplotlib, creating a scatter plot is as simple as using the <code>scatter()</code> function. For example, to create a basic scatter plot with random data points, you can use the following code:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import numpy as np
import matplotlib.pyplot as plt

x = np.random.rand(100)
y = np.random.rand(100)

plt.scatter(x, y)
plt.show()
</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="578" height="441" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-78.png" alt="" class="wp-image-1653057" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-78.png 578w, https://blog.finxter.com/wp-content/uploads/2023/11/image-78-300x229.png 300w" sizes="auto, (max-width: 578px) 100vw, 578px" /></figure>
</div>


<p>But what if you want to display multiple sets of data points, each with a different color? You can simply call the <code>scatter()</code> function multiple times before <code>plt.show()</code> and set the <code>color</code> parameter to a color of your choice:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">plt.scatter(x1, y1, color='red')
plt.scatter(x2, y2, color='blue')
</pre>



<p>Find more details on creating different scatter plots <a href="https://stackoverflow.com/questions/12236566/setting-different-color-for-each-series-in-scatter-plot">here</a>.</p>



<h3 class="wp-block-heading">Building Colorbars</h3>



<p class="has-global-color-8-background-color has-background">Colorbars help in conveying additional information about your data points by assigning colors based on a third variable or their value. To create colorbars with your scatter plot, you need to set the <code>c</code> parameter in the <code>scatter()</code> function, which represents the data points&#8217; colors, and then use the <code>colorbar()</code> function:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import numpy as np
import matplotlib.pyplot as plt

x = np.random.rand(100)
y = np.random.rand(100)

c_values = np.random.rand(100)
plt.scatter(x, y, c=c_values, cmap='viridis')
plt.colorbar()
plt.show()
</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="562" height="439" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-79.png" alt="" class="wp-image-1653058" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-79.png 562w, https://blog.finxter.com/wp-content/uploads/2023/11/image-79-300x234.png 300w" sizes="auto, (max-width: 562px) 100vw, 562px" /></figure>
</div>


<p>In the above example, the colors are set according to the <code>c_values</code> array, using the chosen colormap <code>viridis</code>. You can find more details on adding colorbars to your scatter plots <a href="https://stackoverflow.com/questions/6063876/matplotlib-colorbar-for-scatter">here</a>.</p>



<p></p>



<h2 class="wp-block-heading">Frequently Asked Questions</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="701" src="https://blog.finxter.com/wp-content/uploads/2023/11/image-46-1024x701.jpeg" alt="" class="wp-image-1653059" srcset="https://blog.finxter.com/wp-content/uploads/2023/11/image-46-1024x701.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2023/11/image-46-300x205.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2023/11/image-46-768x525.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2023/11/image-46.jpeg 1216w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h3 class="wp-block-heading">How do I specify a color in Matplotlib using RGB?</h3>



<p>To specify a color using RGB values in Matplotlib, you can use the tuple format <code>(r, g, b)</code>, where <code>r</code>, <code>g</code>, and <code>b</code> are floating-point numbers between 0 and 1 representing the intensity of red, green, and blue, respectively. For example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">plt.plot(x, y, color=(0.5, 0.2, 0.8))
</pre>



<p>This will create a plot with a custom color that has 50% red, 20% green, and 80% blue.</p>



<h3 class="wp-block-heading">What are the default color cycles in Matplotlib?</h3>



<p>Matplotlib uses a default color cycle that is applied to plot elements like lines, markers, and labels. The default cycle includes the following colors, specified with single character shorthand:</p>



<ul class="wp-block-list">
<li><code>b</code>: blue</li>



<li><code>g</code>: green</li>



<li><code>r</code>: red</li>



<li><code>c</code>: cyan</li>



<li><code>m</code>: magenta</li>



<li><code>y</code>: yellow</li>



<li><code>k</code>: black</li>



<li><code>w</code>: white</li>
</ul>



<p>These colors will be used in the order specified when plotting multiple elements in a single plot.</p>



<h3 class="wp-block-heading">How do I convert a hex color to RGB in Matplotlib?</h3>



<p>In Matplotlib, you can convert a hex color to RGB by using the <code>matplotlib.colors.hex2color</code> function. Here&#8217;s an example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.colors as mcolors
hex_color = "#32a852"
rgb_color = mcolors.hex2color(hex_color)
</pre>



<p>This will convert the hex color <code>#32a852</code> to its corresponding RGB tuple <code>(0.196, 0.658, 0.322)</code>.</p>



<h3 class="wp-block-heading">How can I create a custom color map in Matplotlib?</h3>



<p>To create a custom color map in Matplotlib, you can use the <code>matplotlib.colors.LinearSegmentedColormap</code> class. First, define a dictionary that maps the color channel (red, green, or blue) to a list of segments. Each segment is a tuple with three values: <code>(x, y1, y2)</code>, where <code>x</code> is a position between 0 and 1, and <code>y1</code> and <code>y2</code> are color intensities. Here&#8217;s an example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
cmap_data = {
    'red': [(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)],
    'green': [(0.0, 0.0, 0.0), (1.0, 0.0, 0.0)],
    'blue': [(0.0, 0.0, 0.0), (1.0, 0.0, 0.0)],
}
custom_cmap = mcolors.LinearSegmentedColormap('my_cmap', cmap_data)
</pre>



<p>This will create a custom color map that transitions from black to red.</p>



<h3 class="wp-block-heading">What are the available color palettes in Python?</h3>



<p>There are several color palettes available in Python, mainly provided by libraries like Matplotlib and Seaborn. In Matplotlib, you can access a comprehensive <a href="https://matplotlib.org/stable/gallery/color/named_colors.html">list of named colors</a> that includes color names from the CSS specification, X11 colors, and more. In Seaborn, you have access to a variety of color palettes such as qualitative, sequential, and diverging. You can use these palettes in either library, or even create your own custom palettes to suit your needs.</p>



<h3 class="wp-block-heading">How do I use color names in Matplotlib plots?</h3>



<p>Matplotlib supports using color names directly in your plot code. To utilize a color by its name, simply provide the name as a string for the <code>color</code> parameter when plotting. Here&#8217;s an example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">plt.plot(x, y, color='darkviolet')
</pre>



<p>This will create a plot with a line colored in <code>darkviolet</code>.</p>
<p>The post <a href="https://blog.finxter.com/matplotlib-colors-a-comprehensive-guide-for-effective-visualization/">Matplotlib Colors: A Comprehensive Guide for Effective Visualization</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>DALL·E 3 Trick: Using Seeds to Recreate the Same Image</title>
		<link>https://blog.finxter.com/dall%c2%b7e-3-trick-using-seeds-to-recreate-the-same-image/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Mon, 30 Oct 2023 07:35:11 +0000</pubDate>
				<category><![CDATA[DALL·E]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Large Language Model (LLM)]]></category>
		<category><![CDATA[OpenAI]]></category>
		<category><![CDATA[Prompt Engineering]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1652562</guid>

					<description><![CDATA[<p>Problem Formulation You may have encountered the following: When issuing the same prompt twice to ChatGPT with DALL·E 3, you&#8217;ll get different images even though the prompt is identical. How can I recreate the same image in a new Chat, either for myself or for somebody else to reproduce it? Here&#8217;s an example in a ... <a title="DALL·E 3 Trick: Using Seeds to Recreate the Same Image" class="read-more" href="https://blog.finxter.com/dall%c2%b7e-3-trick-using-seeds-to-recreate-the-same-image/" aria-label="Read more about DALL·E 3 Trick: Using Seeds to Recreate the Same Image">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/dall%c2%b7e-3-trick-using-seeds-to-recreate-the-same-image/">DALL·E 3 Trick: Using Seeds to Recreate the Same Image</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Problem Formulation</h2>



<p>You may have encountered the following: </p>



<p class="has-global-color-8-background-color has-background">When issuing the same prompt twice to ChatGPT with DALL·E 3, you&#8217;ll get different images even though the prompt is identical. How can I recreate the same image in a new Chat, either for myself or for somebody else to reproduce it?</p>



<p>Here&#8217;s an example in a fresh chat:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="850" height="648" src="https://blog.finxter.com/wp-content/uploads/2023/10/image-203.png" alt="" class="wp-image-1652563" srcset="https://blog.finxter.com/wp-content/uploads/2023/10/image-203.png 850w, https://blog.finxter.com/wp-content/uploads/2023/10/image-203-300x229.png 300w, https://blog.finxter.com/wp-content/uploads/2023/10/image-203-768x585.png 768w" sizes="auto, (max-width: 850px) 100vw, 850px" /></figure>
</div>


<p>Now, let&#8217;s open a new chat and paste the same prompt:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="858" height="646" src="https://blog.finxter.com/wp-content/uploads/2023/10/image-204.png" alt="" class="wp-image-1652564" srcset="https://blog.finxter.com/wp-content/uploads/2023/10/image-204.png 858w, https://blog.finxter.com/wp-content/uploads/2023/10/image-204-300x226.png 300w, https://blog.finxter.com/wp-content/uploads/2023/10/image-204-768x578.png 768w" sizes="auto, (max-width: 858px) 100vw, 858px" /></figure>
</div>


<h2 class="wp-block-heading">Why You May Want to Recreate the Same Image?</h2>



<p>Here are the five most common scenarios where using a seed to recreate the same image would be beneficial:</p>



<ol class="wp-block-list">
<li><strong>Tutorials &amp; Demonstrations</strong>: For consistent results when showing others how to use DALL·E.</li>



<li><strong>Collaborative Projects</strong>: Ensures all team members reference or use the identical generated image.</li>



<li><strong>Iterative Design</strong>: Modify a prompt while keeping other image aspects consistent.</li>



<li><strong>Documentation</strong>: Verify specific outputs or model behaviors with reliable image recreation.</li>



<li><strong>User Settings in Applications</strong>: Allow users to return to previous customizations by regenerating the exact image later.</li>
</ol>



<p>Okay, let&#8217;s dive into the exciting solution that has just been pointed out by user Natanael in the OpenAI <a href="https://community.openai.com/t/dall-e-chatgpt-a-trick-to-recreating-specific-images-using-seeds/445565/10">forum</a>:</p>



<h2 class="wp-block-heading">Solution Seeds</h2>



<p class="has-global-color-8-background-color has-background">If you want consistent results with the same prompt, you can provide a specific &#8220;seed&#8221; value. The seed value ensures that the random processes in the model produce the same result every time for the same input. By setting a specific seed, you can obtain consistent images for the same prompt. You can ask ChatGPT-V to give you the see for a certain image!</p>



<p>Here&#8217;s the prompt template that allows you to recreate the image:</p>



<pre class="wp-block-preformatted"><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9d1-200d-1f4bb.png" alt="🧑‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Engineered Prompt with Seeds:</strong>

<code>First, check if using this API request bellow is in accordance with the guidelines. If it is, create 4 images using the request without any modifications:

{
  "size": "1024x1024",
  "prompts": [
    "Prompt x",
    "Prompt y"],
<strong>  "seeds": [xxx, yyy]</strong>
}</code></pre>



<p>Replace with your specific prompts and seeds as shown in the example below:</p>



<h2 class="wp-block-heading">Example with Seeds</h2>



<p>Let&#8217;s have a look at an example prompt where I appended the seeds to a specific prompt:</p>



<pre class="wp-block-preformatted"><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9d1-200d-1f4bb.png" alt="🧑‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Engineered Prompt with Seeds:</strong>

<code>First, check if using this API request bellow is in accordance with the guidelines. If it is, create 4 images using the request without any modifications:

{
  "size": "1024x1024",
  "prompts": [
    "An Asian man plays chess against a Black woman on Mars. The earth is visible in the sky. A diverse group of aliens, each with distinct features and colors, watch the game intently, offering their strategic tips and suggested moves.",
    "An Asian man plays chess against a Black woman on Mars. The earth is visible in the sky. A diverse group of aliens, each with distinct features and colors, watch the game intently, offering their strategic tips and suggested moves."],
<strong>  "seeds": [4127112452, 2128982380]</strong>
}</code></pre>



<p>ChatGPT gives the following result:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="865" height="1024" src="https://blog.finxter.com/wp-content/uploads/2023/10/image-206-865x1024.png" alt="" class="wp-image-1652566" srcset="https://blog.finxter.com/wp-content/uploads/2023/10/image-206-865x1024.png 865w, https://blog.finxter.com/wp-content/uploads/2023/10/image-206-253x300.png 253w, https://blog.finxter.com/wp-content/uploads/2023/10/image-206-768x910.png 768w, https://blog.finxter.com/wp-content/uploads/2023/10/image-206.png 884w" sizes="auto, (max-width: 865px) 100vw, 865px" /></figure>
</div>


<p>Now let&#8217;s open a new chat, paste the same prompt but append the seed information like so:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="754" height="1024" src="https://blog.finxter.com/wp-content/uploads/2023/10/image-207-754x1024.png" alt="" class="wp-image-1652567" srcset="https://blog.finxter.com/wp-content/uploads/2023/10/image-207-754x1024.png 754w, https://blog.finxter.com/wp-content/uploads/2023/10/image-207-221x300.png 221w, https://blog.finxter.com/wp-content/uploads/2023/10/image-207-768x1044.png 768w, https://blog.finxter.com/wp-content/uploads/2023/10/image-207.png 850w" sizes="auto, (max-width: 754px) 100vw, 754px" /></figure>



<p><strong>Can you spot the slight differences? </strong>Now you may wonder whether ChatGPT would&#8217;ve created the same without the seeds? I tried that and it didn&#8217;t!</p>



<h2 class="wp-block-heading">Example Without Seeds</h2>



<p>The same prompt but without specifying seeds leads to this image:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="836" height="936" src="https://blog.finxter.com/wp-content/uploads/2023/10/image-208.png" alt="" class="wp-image-1652568" srcset="https://blog.finxter.com/wp-content/uploads/2023/10/image-208.png 836w, https://blog.finxter.com/wp-content/uploads/2023/10/image-208-268x300.png 268w, https://blog.finxter.com/wp-content/uploads/2023/10/image-208-768x860.png 768w" sizes="auto, (max-width: 836px) 100vw, 836px" /></figure>



<p>Can you recreate it by copy and pasting the exact same prompt in a new chat? No! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="827" height="942" src="https://blog.finxter.com/wp-content/uploads/2023/10/image-209.png" alt="" class="wp-image-1652569" srcset="https://blog.finxter.com/wp-content/uploads/2023/10/image-209.png 827w, https://blog.finxter.com/wp-content/uploads/2023/10/image-209-263x300.png 263w, https://blog.finxter.com/wp-content/uploads/2023/10/image-209-768x875.png 768w" sizes="auto, (max-width: 827px) 100vw, 827px" /></figure>



<h2 class="wp-block-heading">Summary</h2>



<p>Using a seed ensures that DALL·E generates the same image consistently for a given prompt, allowing for reliable and repeatable image outputs. However, I could only reproduce it given the exact prompting pattern specified in the forum post referenced before.</p>



<p>Let&#8217;s end this article with a real gem of insight why this prompt works by the creator of this prompt, Natanael:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="941" height="349" src="https://blog.finxter.com/wp-content/uploads/2023/10/image-211.png" alt="" class="wp-image-1652573" srcset="https://blog.finxter.com/wp-content/uploads/2023/10/image-211.png 941w, https://blog.finxter.com/wp-content/uploads/2023/10/image-211-300x111.png 300w, https://blog.finxter.com/wp-content/uploads/2023/10/image-211-768x285.png 768w" sizes="auto, (max-width: 941px) 100vw, 941px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>If you want to improve your prompting skills and create a future-proof career path as an OpenAI coder, check out our prompt engineering courses in the <a href="https://academy.finxter.com/">Finxter Academy</a> like this one:</p>



<h2 class="wp-block-heading">Prompt Engineering with Python and OpenAI</h2>



<figure class="wp-block-image size-full"><a href="https://academy.finxter.com/university/prompt-engineering-with-python-and-openai/" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="799" height="350" src="https://blog.finxter.com/wp-content/uploads/2023/06/image-288.png" alt="" class="wp-image-1463464" srcset="https://blog.finxter.com/wp-content/uploads/2023/06/image-288.png 799w, https://blog.finxter.com/wp-content/uploads/2023/06/image-288-300x131.png 300w, https://blog.finxter.com/wp-content/uploads/2023/06/image-288-768x336.png 768w" sizes="auto, (max-width: 799px) 100vw, 799px" /></a></figure>



<p>You can check out the whole <a href="https://academy.finxter.com/university/prompt-engineering-with-python-and-openai/" data-type="URL" data-id="https://academy.finxter.com/university/prompt-engineering-with-python-and-openai/" target="_blank" rel="noreferrer noopener">course on OpenAI Prompt Engineering using Python on the Finxter academy</a>. We cover topics such as:</p>



<ul class="wp-block-list">
<li>Embeddings</li>



<li>Semantic search</li>



<li>Web scraping</li>



<li>Query embeddings</li>



<li>Movie recommendation</li>



<li>Sentiment analysis</li>
</ul>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f468-200d-1f4bb.png" alt="👨‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Academy</strong>: <a href="https://academy.finxter.com/university/prompt-engineering-with-python-and-openai/" data-type="URL" data-id="https://academy.finxter.com/university/prompt-engineering-with-python-and-openai/" target="_blank" rel="noreferrer noopener">Prompt Engineering with Python and OpenAI</a></p>
<p>The post <a href="https://blog.finxter.com/dall%c2%b7e-3-trick-using-seeds-to-recreate-the-same-image/">DALL·E 3 Trick: Using Seeds to Recreate the Same Image</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python Code for Getting Historical Weather Data</title>
		<link>https://blog.finxter.com/python-code-for-getting-historical-weather-data/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Wed, 13 Sep 2023 15:35:05 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web Scraping]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1651525</guid>

					<description><![CDATA[<p>To get historical weather data in Python, install the Meteostat library using pip install meteostat or run !pip install meteostat with the exclamation mark prefix ! in a Jupyter Notebook. If you haven&#8217;t already, also install the Matplotlib library using pip install matplotlib. Then, copy the following code into your programming environment and change the ... <a title="Python Code for Getting Historical Weather Data" class="read-more" href="https://blog.finxter.com/python-code-for-getting-historical-weather-data/" aria-label="Read more about Python Code for Getting Historical Weather Data">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/python-code-for-getting-historical-weather-data/">Python Code for Getting Historical Weather Data</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>To get historical weather data in Python, install the Meteostat library using <code>pip install meteostat</code> or run <code>!pip install meteostat</code> with the exclamation mark prefix <code>!</code> in a Jupyter Notebook. </p>



<p>If you haven&#8217;t already, also install the Matplotlib library using <code>pip install matplotlib</code>.</p>



<p>Then, copy the following code into your programming environment and change the highlighted lines to set your own timeframe (<code>start</code>, <code>end</code>) and GPS <code>location</code>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="7,8,11" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Import Meteostat library and dependencies
from datetime import datetime
import matplotlib.pyplot as plt
from meteostat import Point, Daily

# Set time period
start = datetime(2023, 1, 1)
end = datetime(2023, 12, 31)

# Create Point for Stuttgart, Germany
location = Point(48.787399767583295, 9.205803269767616)

# Get daily data for 2023
data = Daily(location, start, end)
data = data.fetch()

# Plot line chart including average, minimum and maximum temperature
data.plot(y=['tavg', 'tmin', 'tmax'])
plt.show()</pre>



<p>This code fetches and visualizes the average, minimum, and maximum temperatures for <em>Stuttgart, Germany</em>, for the entire year of 2023 using the <a href="https://dev.meteostat.net/python/">Meteostat library</a>.</p>



<p>Here&#8217;s the output:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="543" height="449" src="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-5.png" alt="" class="wp-image-1651528" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-5.png 543w, https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-5-300x248.png 300w" sizes="auto, (max-width: 543px) 100vw, 543px" /></figure>
</div>


<p>Here are the three highlighted lines:</p>



<ul class="wp-block-list">
<li><code>start = datetime(2023, 1, 1)</code>: This sets the start date to January 1, 2023.</li>



<li><code>end = datetime(2023, 12, 31)</code>: This sets the end date to December 31, 2023. Together, these lines define the time period for which we want to fetch the weather data.</li>



<li><code>location = Point(48.787399767583295, 9.205803269767616)</code>: This creates a geographical point for Stuttgart, Germany using its latitude and longitude GPS coordinates. The <code><a href="https://dev.meteostat.net/python/api/point/#parameters">Point</a></code> class is used to represent a specific location on Earth.</li>
</ul>



<p>You can use <a href="https://www.google.com/maps">Google Maps</a> to copy the GPS location of your desired location:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="804" src="https://blog.finxter.com/wp-content/uploads/2023/09/image-72-1024x804.png" alt="" class="wp-image-1651526" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/image-72-1024x804.png 1024w, https://blog.finxter.com/wp-content/uploads/2023/09/image-72-300x236.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/image-72-768x603.png 768w, https://blog.finxter.com/wp-content/uploads/2023/09/image-72.png 1525w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>You can try it yourself in the interactive Jupyter notebook (Google Colab):</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://colab.research.google.com/drive/1qdbzBwmlfK--eE7X05zmAI7AkMMgAikR?usp=sharing" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="691" height="460" src="https://blog.finxter.com/wp-content/uploads/2023/09/image-73.png" alt="" class="wp-image-1651530" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/image-73.png 691w, https://blog.finxter.com/wp-content/uploads/2023/09/image-73-300x200.png 300w" sizes="auto, (max-width: 691px) 100vw, 691px" /></a></figure>
</div>


<p>If you want to become a Python master, get free cheat sheets, and coding books, check out the free Finxter email academy with 150,000 coders like you:</p>



<p>The post <a href="https://blog.finxter.com/python-code-for-getting-historical-weather-data/">Python Code for Getting Historical Weather Data</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Want Exploding Bitcoin Prices North of $500,000 per BTC? &#8220;Grow N&#8221; Says Metcalfe&#8217;s Law</title>
		<link>https://blog.finxter.com/want-exploding-prices-north-of-500000-per-btc-grow-n-says-metcalfes-law-model/</link>
		
		<dc:creator><![CDATA[Jean Rousseau]]></dc:creator>
		<pubDate>Sun, 03 Sep 2023 06:29:45 +0000</pubDate>
				<category><![CDATA[Bitcoin]]></category>
		<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Investment]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1651267</guid>

					<description><![CDATA[<p>Metcalfe&#8217;s law states that the value of a network (V) is proportional to the square of the number of connected users of the system (N²). In this article, I&#8217;ll develop a Bitcoin price prediction (V) in the year 2030 based on the average growth rate of the number of Bitcoin nodes (N). General Intuition Metcalfe&#8217;s ... <a title="Want Exploding Bitcoin Prices North of $500,000 per BTC? &#8220;Grow N&#8221; Says Metcalfe&#8217;s Law" class="read-more" href="https://blog.finxter.com/want-exploding-prices-north-of-500000-per-btc-grow-n-says-metcalfes-law-model/" aria-label="Read more about Want Exploding Bitcoin Prices North of $500,000 per BTC? &#8220;Grow N&#8221; Says Metcalfe&#8217;s Law">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/want-exploding-prices-north-of-500000-per-btc-grow-n-says-metcalfes-law-model/">Want Exploding Bitcoin Prices North of $500,000 per BTC? &#8220;Grow N&#8221; Says Metcalfe&#8217;s Law</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-global-color-8-background-color has-background">Metcalfe&#8217;s law states that <strong>the value of a network (V) is proportional to the square of the number of connected users of the system (N²)</strong>. In this article, I&#8217;ll develop a Bitcoin price prediction (V) in the year 2030 based on the average growth rate of the number of Bitcoin nodes (N).</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="510" height="909" src="https://blog.finxter.com/wp-content/uploads/2023/09/image-7.png" alt="" class="wp-image-1651288" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/image-7.png 510w, https://blog.finxter.com/wp-content/uploads/2023/09/image-7-168x300.png 168w" sizes="auto, (max-width: 510px) 100vw, 510px" /></figure>
</div>


<h2 class="wp-block-heading">General Intuition Metcalfe&#8217;s Law</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="753" height="753" src="https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__a8852a5c-c9e1-4f8d-af39-2dc06fae270d.png" alt="" class="wp-image-1651290" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__a8852a5c-c9e1-4f8d-af39-2dc06fae270d.png 753w, https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__a8852a5c-c9e1-4f8d-af39-2dc06fae270d-300x300.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__a8852a5c-c9e1-4f8d-af39-2dc06fae270d-150x150.png 150w" sizes="auto, (max-width: 753px) 100vw, 753px" /></figure>
</div>


<p>Metcalfe&#8217;s law states that the value of a network is proportional to the square of the number of connected users of the system (N^2). This law was initially formulated in the context of telecommunications networks by Robert Metcalfe, the inventor of Ethernet.</p>



<p>The intuition behind Metcalfe&#8217;s law is relatively straightforward:</p>



<ol class="wp-block-list">
<li><strong>Value of Connections</strong>: The value of a network to a user is proportional to the number of other users they can connect with. For example, a telephone is useless if you are the only one who has one, but becomes more valuable as more people get telephones.</li>



<li><strong>Number of Connections</strong>: The number of possible connections between users in a network increases quadratically with the number of users. Specifically, the number of possible connections between <code>N</code> users is <code>N(N-1)/2</code>, which is proportional to <code>N^2</code>.</li>
</ol>



<p>So, the idea is that as the number of users in a network increases, the number of possible connections between users increases quadratically, and therefore the value of the network also increases quadratically.</p>



<p>This intuition can be applied to various types of networks, including social networks, the internet, and even cryptocurrencies like Bitcoin. For example, the value of a social network like Facebook increases as more people join the network because each user can connect with more people. Similarly, the value of Bitcoin may increase as more people use it because it becomes more useful as a means of exchange.</p>



<h2 class="wp-block-heading">Why Does Metcalfe&#8217;s Law Apply to Bitcoin?</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="753" height="753" src="https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__015574ef-fb94-49d6-ac39-043e3099687a.png" alt="" class="wp-image-1651291" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__015574ef-fb94-49d6-ac39-043e3099687a.png 753w, https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__015574ef-fb94-49d6-ac39-043e3099687a-300x300.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__015574ef-fb94-49d6-ac39-043e3099687a-150x150.png 150w" sizes="auto, (max-width: 753px) 100vw, 753px" /></figure>
</div>


<p>Metcalfe&#8217;s law can be applied to Bitcoin for several reasons:</p>



<ol class="wp-block-list">
<li><strong>Network Effect</strong>: Bitcoin, like other networks, benefits from the network effect. The more people, businesses, and institutions that use and accept Bitcoin, the more valuable it becomes as a medium of exchange. This is because each new user increases the number of potential transactions and, therefore, the utility of the network for all users.</li>



<li><strong>Number of Connections</strong>: The number of possible connections between users in the Bitcoin network increases with the number of users. As more people use Bitcoin, the number of potential transactions increases, which increases the utility and, therefore, the value of the network.</li>



<li><strong>Decentralization</strong>: Bitcoin is a decentralized network, meaning that it is not controlled by any single entity. This makes it more resilient and potentially more valuable as more nodes (computers running the Bitcoin software) join the network and contribute to its security and stability.</li>



<li><strong>Historical Correlation</strong>: Some <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3078248">studies</a> have found a correlation between the market value of Bitcoin and the square of the number of active users or other network metrics. This suggests that Metcalfe&#8217;s law may be a useful model for estimating the value of Bitcoin.</li>
</ol>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="906" height="533" src="https://blog.finxter.com/wp-content/uploads/2023/09/image-5.png" alt="" class="wp-image-1651278" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/image-5.png 906w, https://blog.finxter.com/wp-content/uploads/2023/09/image-5-300x176.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/image-5-768x452.png 768w" sizes="auto, (max-width: 906px) 100vw, 906px" /></figure>
</div>


<h2 class="wp-block-heading">But Bitcoin is a Store of Value More Than a Medium of Exchange&#8230;</h2>



<p>If you&#8217;re like me, you believe that currently Bitcoin is more a store of value than a medium of exchange. So does Metcalfe&#8217;s Law apply in the first place? I have put some thoughts into this. </p>



<p>When viewing Bitcoin as a store of value, Metcalfe&#8217;s Law can still be applied, but with a slightly different perspective.</p>



<ol class="wp-block-list">
<li><strong>Network Security</strong>: The security of the Bitcoin network is crucial for its role as a store of value. The more nodes and miners there are in the network, the more secure it is against attacks. This increased security enhances its value as a store of value. According to Metcalfe&#8217;s Law, the value of a network is proportional to the square of the number of connected users. In the context of Bitcoin as a store of value, this could be interpreted as the value of Bitcoin increasing with the square of the number of participants (nodes, miners, and users) in the network.</li>



<li><strong>Liquidity</strong>: For any asset to be a good store of value, it needs to be liquid, meaning it can be easily bought or sold. The more participants there are in the Bitcoin network, the more liquid it becomes, which enhances its value as a store of value.</li>



<li><strong>Acceptance and Adoption</strong>: The more widely accepted and used Bitcoin is, the more valuable it becomes as a store of value. This is because widespread acceptance and use increase the demand for Bitcoin, which in turn increases its value.</li>



<li><strong>Trust</strong>: Trust is a crucial factor for any store of value. The more participants there are in the Bitcoin network, the more trust is built in the network&#8217;s security and stability, which enhances its value as a store of value.</li>
</ol>



<p>So, even when viewing Bitcoin as a store of value, Metcalfe&#8217;s Law can still be applied in the sense that the value of Bitcoin as a store of value increases with the square of the number of participants in the network.</p>



<h2 class="wp-block-heading">What Is &#8220;N&#8221; in Metcalfe&#8217;s Law for Bitcoin?</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="753" height="753" src="https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__2408d58d-b5ff-47ec-8cac-85df857ee0df.png" alt="" class="wp-image-1651292" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__2408d58d-b5ff-47ec-8cac-85df857ee0df.png 753w, https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__2408d58d-b5ff-47ec-8cac-85df857ee0df-300x300.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__2408d58d-b5ff-47ec-8cac-85df857ee0df-150x150.png 150w" sizes="auto, (max-width: 753px) 100vw, 753px" /></figure>
</div>


<p>Getting the exact number of people participating in the Bitcoin network can be quite challenging due to the decentralized and pseudonymous nature of the network. </p>



<p>However, there are several proxies or indicators that you can use to estimate the number of participants:</p>



<ol class="wp-block-list">
<li><strong>Number of Active Addresses</strong>: This is the number of unique addresses that were active in the network (either as a sender or a receiver) during a certain period. This data can be obtained from various blockchain analytics platforms like CoinMetrics, Blockchain.com, or Bitinfocharts.</li>



<li><strong>Number of Wallets</strong>: This is the number of unique wallets that hold Bitcoin. This data can also be obtained from blockchain analytics platforms. However, it is important to note that one person can own multiple wallets, so this may not be a perfect measure of the number of participants.</li>



<li><strong>Number of Transactions</strong>: This is the number of transactions that occur on the Bitcoin network during a certain period. This data can be obtained from the same blockchain analytics platforms mentioned above.</li>



<li><strong>Number of Nodes</strong>: This is the number of nodes participating in the Bitcoin network. A node is a computer running the Bitcoin software that helps to maintain the network by validating transactions and blocks. This data can be obtained from websites like Bitnodes.</li>



<li><strong>Number of Miners</strong>: This is the number of miners participating in the Bitcoin network. Miners are nodes that validate and confirm transactions by solving complex mathematical problems. This data can be more difficult to obtain because many miners participate in mining pools, and the exact number of individual miners within a pool may not be publicly available.</li>
</ol>



<p>None of these metrics are perfect proxies for the number of participants in the Bitcoin network, as one person can own multiple addresses, wallets, and nodes. Additionally, some addresses and wallets may be owned by exchanges or other institutions rather than individual participants.</p>



<p>The <strong>number of wallets</strong> is not a great metric for Metcalfe&#8217;s Law because most Bitcoiners own multiple wallets. At the same time, exchanges may have a small number of wallets for a huge number of Bitcoin holders. </p>



<p class="has-global-color-8-background-color has-background">There&#8217;s a strong argument, however, that the <strong>number of nodes</strong> captures the number of &#8220;hardcore Bitcoiners&#8221; best because there&#8217;s no incentive to run <em>multiple </em>nodes. Thus, this metric is a conservative measure of the network size. Also, the Blocksize wars have shown that the Bitcoin nodes are the true sources of decentralization in the Bitcoin network. Literally, the decentralization of the Bitcoin network is determined by the decentralization of Bitcoin nodes.</p>



<h2 class="wp-block-heading">How Many Bitcoin Nodes Are There?</h2>



<p><a href="https://bitnodes.io/dashboard/7y/">Bitnodes.io</a> estimates that there are 45,190 Bitcoin nodes in September 2023 and 16,279 reachable nodes:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="484" src="https://blog.finxter.com/wp-content/uploads/2023/09/image-2-1024x484.png" alt="" class="wp-image-1651269" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/image-2-1024x484.png 1024w, https://blog.finxter.com/wp-content/uploads/2023/09/image-2-300x142.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/image-2-768x363.png 768w, https://blog.finxter.com/wp-content/uploads/2023/09/image-2.png 1406w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Here&#8217;s the distribution of reachable nodes by country:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="445" src="https://blog.finxter.com/wp-content/uploads/2023/09/image-3-1024x445.png" alt="" class="wp-image-1651270" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/image-3-1024x445.png 1024w, https://blog.finxter.com/wp-content/uploads/2023/09/image-3-300x130.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/image-3-768x334.png 768w, https://blog.finxter.com/wp-content/uploads/2023/09/image-3.png 1407w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Another chart from <a href="https://coin.dance/nodes/all">another source</a> measuring the number of Bitcoin nodes since 2015: </p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="473" src="https://blog.finxter.com/wp-content/uploads/2023/09/image-4-1024x473.png" alt="" class="wp-image-1651271" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/image-4-1024x473.png 1024w, https://blog.finxter.com/wp-content/uploads/2023/09/image-4-300x139.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/image-4-768x355.png 768w, https://blog.finxter.com/wp-content/uploads/2023/09/image-4.png 1428w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>It shows a similar order of magnitude, so let&#8217;s take this as it goes back to 2015.</p>



<p>Here&#8217;s a table for the rough number of reachable nodes by year (in August) and Bitcoin price (in August):</p>



<figure class="wp-block-table is-style-stripes"><table><thead><tr><th>Year</th><th>Number of Bitcoin Nodes</th><th>Bitcoin Price ($)</th></tr></thead><tbody><tr><td>2015</td><td>6430</td><td>279</td></tr><tr><td>2016</td><td>5220</td><td>588</td></tr><tr><td>2017</td><td>7740</td><td>3341</td></tr><tr><td>2018</td><td>9370</td><td>7634</td></tr><tr><td>2019</td><td>9270</td><td>11476</td></tr><tr><td>2020</td><td>10070</td><td>11246</td></tr><tr><td>2021</td><td>12090</td><td>39178</td></tr><tr><td>2022</td><td>12920</td><td>23179</td></tr><tr><td>2023</td><td>16550</td><td>29043</td></tr></tbody></table></figure>



<p></p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Recap</strong>: Metcalfe&#8217;s Law states that the value of a network is proportional to the square of the number of connected users of the system (n^2).</p>



<p>Let&#8217;s apply this to your data. </p>



<p class="has-global-color-8-background-color has-background">We will use the number of Bitcoin nodes as a proxy for the number of users in the network. According to Metcalfe&#8217;s Law, the value of the Bitcoin network (which we will proxy with the Bitcoin price) should be proportional to the square of the number of nodes.</p>



<p>Here is a simple model using this data:</p>



<figure class="wp-block-table is-style-stripes"><table><thead><tr><th>Year</th><th>Number of Bitcoin Nodes</th><th>Bitcoin Price ($)</th><th>Nodes Squared</th></tr></thead><tbody><tr><td>2015</td><td>6430</td><td>279</td><td>41,316,900</td></tr><tr><td>2016</td><td>5220</td><td>588</td><td>27,264,400</td></tr><tr><td>2017</td><td>7740</td><td>3341</td><td>59,923,600</td></tr><tr><td>2018</td><td>9370</td><td>7634</td><td>87,796,900</td></tr><tr><td>2019</td><td>9270</td><td>11476</td><td>85,992,900</td></tr><tr><td>2020</td><td>10070</td><td>11246</td><td>101,407,600</td></tr><tr><td>2021</td><td>12090</td><td>39178</td><td>146,168,100</td></tr><tr><td>2022</td><td>12920</td><td>23179</td><td>166,886,400</td></tr><tr><td>2023</td><td>16550</td><td>29043</td><td>273,902,500</td></tr></tbody></table></figure>



<p>Now, you can plot the Bitcoin price against the number of nodes squared and fit a regression line to the data to see how well Metcalfe&#8217;s Law fits the data.</p>



<h2 class="wp-block-heading">Validating the Model</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="589" height="455" src="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-1.png" alt="" class="wp-image-1651274" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-1.png 589w, https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-1-300x232.png 300w" sizes="auto, (max-width: 589px) 100vw, 589px" /></figure>



<p>How did I create this chart?</p>



<p>Here is how you can do it in Python: First, install the libraries if you haven&#8217;t already by running <code>pip install pandas matplotlib scikit-learn</code> in your terminal. Second, run the following Python script:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression

# Create a DataFrame with your data
data = {
    'Year': [2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023],
    'Nodes': [6430, 5220, 7740, 9370, 9270, 10070, 12090, 12920, 16550],
    'Price': [279, 588, 3341, 7634, 11476, 11246, 39178, 23179, 29043]
}
df = pd.DataFrame(data)

# Create a new column for the number of nodes squared
df['Nodes Squared'] = df['Nodes'] ** 2

# Create a scatter plot of the data
plt.scatter(df['Nodes Squared'], df['Price'])
plt.xlabel('Nodes Squared')
plt.ylabel('Bitcoin Price ($)')
plt.title('Bitcoin Price vs Nodes Squared')
plt.show()

# Fit a linear regression model
X = df[['Nodes Squared']]
y = df['Price']
model = LinearRegression().fit(X, y)

# Print the coefficients
print('Intercept:', model.intercept_)
print('Slope:', model.coef_[0])

# Predict the Bitcoin price using the model
df['Predicted Price'] = model.predict(X)

# Plot the actual vs predicted prices
plt.scatter(df['Nodes Squared'], df['Price'], color='blue', label='Actual')
plt.plot(df['Nodes Squared'], df['Predicted Price'], color='red', label='Predicted')
plt.xlabel('Nodes Squared')
plt.ylabel('Bitcoin Price ($)')
plt.title('Actual vs Predicted Bitcoin Price')
plt.legend()
plt.show()
</pre>



<p>This script will create a <strong>scatter plot of the Bitcoin price against the number of nodes squared, fit a linear regression model to the data, and then plot the actual vs predicted Bitcoin prices.</strong> </p>



<p>The intercept and slope of the regression line will be printed in the console.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="589" height="455" src="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled.png" alt="" class="wp-image-1651273" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled.png 589w, https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-300x232.png 300w" sizes="auto, (max-width: 589px) 100vw, 589px" /></figure>



<p><strong>Intercept</strong>: <code>-1843.9665728454092 </code><br><strong>Slope</strong>: <code>0.00014390774052419503</code></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="589" height="455" src="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-1.png" alt="" class="wp-image-1651274" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-1.png 589w, https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-1-300x232.png 300w" sizes="auto, (max-width: 589px) 100vw, 589px" /></figure>



<p>The script provided does both the scatter plot and the linear regression. The first plot is a scatter plot of the actual data, and the second plot includes both the scatter plot of the actual data and the predicted Bitcoin prices from the linear regression model (the red line).</p>



<p>The takeaway from the plot shows that the number of nodes squared (a proxy for the network size according to Metcalfe&#8217;s Law) explains the variation in Bitcoin prices. If the red line (predicted prices) fits closely with the blue dots (actual prices), it suggests that the model and Metcalfe&#8217;s Law are good at explaining the variation in Bitcoin prices. </p>



<p>For example, you can see that the 2021 Bitcoin price at $40,000 was flagged as &#8220;overvalued&#8221; by the model whereas today&#8217;s $27,000 price would be flagged as &#8220;undervalued&#8221; based on the real number of nodes.</p>



<h2 class="wp-block-heading">Bitcoin Price Formula Based on Metcalfe&#8217;s Law</h2>



<p>The slope and intercept of the regression line will give you a mathematical model that you can use to predict Bitcoin prices based on the number of nodes squared.</p>



<p>In our simple case, the slope and intercept are:</p>



<ul class="wp-block-list">
<li><strong>Intercept</strong>: -1843.9665728454092 </li>



<li><strong>Slope</strong>: 0.00014390774052419503</li>
</ul>



<p>The formula would be:</p>



<pre class="wp-block-preformatted"><code>Bitcoin Price = 0.00014390774052419503 × N² - 1843</code></pre>



<p>whereas N is the number of Bitcoin nodes according to <a href="https://coin.dance/nodes/all">this data</a>.</p>



<h2 class="wp-block-heading">What&#8217;s Bitcoin&#8217;s Historic Growth Rate of N?</h2>



<p>To analyze the node growth rates, you can compute the year-over-year growth rate in the number of nodes and then use that to project the number of nodes 5 years into the future. Then, you can use the projected number of nodes and your regression model to predict the Bitcoin price 5 years into the future.</p>



<p>Here are the year-over-year growth rates in the number of nodes from your data:</p>



<figure class="wp-block-table is-style-stripes"><table><thead><tr><th>Year</th><th>Number of Bitcoin Nodes</th><th>YoY Growth Rate (%)</th></tr></thead><tbody><tr><td>2015</td><td>6430</td><td>&#8211;</td></tr><tr><td>2016</td><td>5220</td><td>-18.8</td></tr><tr><td>2017</td><td>7740</td><td>48.3</td></tr><tr><td>2018</td><td>9370</td><td>21.0</td></tr><tr><td>2019</td><td>9270</td><td>-1.1</td></tr><tr><td>2020</td><td>10070</td><td>8.6</td></tr><tr><td>2021</td><td>12090</td><td>20.1</td></tr><tr><td>2022</td><td>12920</td><td>6.9</td></tr><tr><td>2023</td><td>16550</td><td>28.1</td></tr></tbody></table></figure>



<p>The average year-over-year growth rate from 2016 to 2023 is about 11.5%.</p>



<h2 class="wp-block-heading">Bitcoin to $500k in 2030? Yes. If We Grow the Number of Nodes (N) by 20% per Year! </h2>



<p>Here is a Python script that will compute the year-over-year growth rates in the number of nodes, project the number of nodes 5 years into the future, and then use your regression model to predict the Bitcoin price 5 years into the future. It will also create a visualization of the actual and predicted Bitcoin prices.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="867" height="547" src="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-4.png" alt="" class="wp-image-1651287" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-4.png 867w, https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-4-300x189.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/Untitled-4-768x485.png 768w" sizes="auto, (max-width: 867px) 100vw, 867px" /></figure>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import pandas as pd
import matplotlib.pyplot as plt

# Create a DataFrame with your data
data = {
    'Year': [2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023],
    'Nodes': [6430, 5220, 7740, 9370, 9270, 10070, 12090, 12920, 16550],
    'Price': [279, 588, 3341, 7634, 11476, 11246, 39178, 23179, 29043]
}
df = pd.DataFrame(data)

# Define the regression model parameters
intercept = -1843.9665728454092
slope = 0.00014390774052419503

# Define the growth rates and years for prediction
growth_rates = [0.05, 0.10, 0.15, 0.20]
years = range(2024, 2031)

# Create a plot
plt.figure(figsize=(10, 6))

# Plot the actual data as small dots
plt.scatter(df['Year'], df['Price'], color='black', s=10)

# Plot the predicted model prices for 2015 to 2023 based on the real number of nodes
model_price = [(slope * nodes ** 2 + intercept) for nodes in df['Nodes']]
# plt.plot(df['Year'], model_price, 'k--', label='Model Predicted')

# For each growth rate, project the number of nodes and predict the Bitcoin price
for growth_rate in growth_rates:
    # Project the number of nodes
    projected_nodes = [df['Nodes'].iloc[-1] * (1 + growth_rate) ** (year - 2023) for year in years]
    # Predict the Bitcoin price
    projected_price = [(slope * nodes ** 2 + intercept) for nodes in projected_nodes]
    # Plot the predicted prices
    plt.plot(list(df['Year']) + list(years), model_price + projected_price, label=f'Predicted (Growth Rate: {growth_rate * 100}%)')
    # Label the end values
    plt.text(2030, projected_price[-1], f'${projected_price[-1]:,.0f}', verticalalignment='center')

# Add labels and a legend
plt.xlabel('Year')
plt.ylabel('Bitcoin Price ($)')
plt.yscale('log')
plt.xlim(2014, 2032)
plt.title('Actual vs Predicted Bitcoin Price')
plt.legend()

# Show the plot
plt.show()
</pre>



<p>This script creates a line chart with the actual Bitcoin prices from 2015 to 2023 plotted as small dots, the predicted model prices for 2015 to 2023 based on the real number of nodes, and the predicted prices from 2024 to 2030 for different growth rates of the number of nodes. The y-axis is on a logarithmic scale.</p>



<h2 class="wp-block-heading">Want Exploding Prices? &#8220;Grow N&#8221; Says Metcalfe&#8217;s Law</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="753" height="753" src="https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__6d46c3f1-bd56-4898-9613-3a44f2d48daa.png" alt="" class="wp-image-1651293" srcset="https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__6d46c3f1-bd56-4898-9613-3a44f2d48daa.png 753w, https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__6d46c3f1-bd56-4898-9613-3a44f2d48daa-300x300.png 300w, https://blog.finxter.com/wp-content/uploads/2023/09/Finxter_A_Bitcoin_symbol_in_a_cyberspace_environment_with_many__6d46c3f1-bd56-4898-9613-3a44f2d48daa-150x150.png 150w" sizes="auto, (max-width: 753px) 100vw, 753px" /></figure>
</div>


<p>The analysis clearly demonstrates a mathematical relationship between the number of Bitcoin nodes and its price, as predicted by Metcalfe&#8217;s Law. This relationship, quantified by a positive coefficient in the regression model, indicates that <strong>as the number of nodes increases, the price of Bitcoin is predicted to increase quadratically.</strong> </p>



<p>Therefore, if we want to see higher Bitcoin prices in the future, it is imperative to <strong>focus on growing the number of nodes in the Bitcoin network</strong>. </p>



<p>This calls for a collective effort from the Bitcoin community and stakeholders to encourage and facilitate the addition of more nodes to the network, thereby strengthening its security, decentralization, and, ultimately, its value.</p>



<p>Also, feel free to subscribe to our <a href="https://blog.finxter.com/email-academy/">free email academy</a> on exponential technologies by downloading our Python cheat sheets here:</p>






<p>You can reply to any of my emails (e.g., with your own analysis based on Metcalfe&#8217;s Law) to keep the conversation going. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a href="https://blog.finxter.com/want-exploding-prices-north-of-500000-per-btc-grow-n-says-metcalfes-law-model/">Want Exploding Bitcoin Prices North of $500,000 per BTC? &#8220;Grow N&#8221; Says Metcalfe&#8217;s Law</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How I Created Charts Using Charts.js in Django Web Application</title>
		<link>https://blog.finxter.com/how-i-created-charts-using-charts-js-in-django-web-application/</link>
		
		<dc:creator><![CDATA[Jonathan Okah]]></dc:creator>
		<pubDate>Fri, 04 Aug 2023 14:37:00 +0000</pubDate>
				<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web Development]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1547017</guid>

					<description><![CDATA[<p>If you want to display charts in your Django web application, whether it is a bar chart, a pie chart, or other charts, you have so many options at your disposal &#8212; from using Plotly in Python language to using HighCharts.js or Charts.js in JavaScript. The beauty of using the later over the former is ... <a title="How I Created Charts Using Charts.js in Django Web Application" class="read-more" href="https://blog.finxter.com/how-i-created-charts-using-charts-js-in-django-web-application/" aria-label="Read more about How I Created Charts Using Charts.js in Django Web Application">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/how-i-created-charts-using-charts-js-in-django-web-application/">How I Created Charts Using Charts.js in Django Web Application</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>If you want to display charts in your Django web application, whether it is a bar chart, a pie chart, or other charts, you have so many options at your disposal &#8212; from using <a href="https://blog.finxter.com/plotly-dash-vs-streamlit/" data-type="post" data-id="997098" target="_blank" rel="noreferrer noopener">Plotly</a> in Python language to using <code>HighCharts.js</code> or <code>Charts.js</code> in JavaScript.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="720" height="405" src="https://blog.finxter.com/wp-content/uploads/2023/08/image-33.png" alt="" class="wp-image-1547022" srcset="https://blog.finxter.com/wp-content/uploads/2023/08/image-33.png 720w, https://blog.finxter.com/wp-content/uploads/2023/08/image-33-300x169.png 300w" sizes="auto, (max-width: 720px) 100vw, 720px" /></figure>
</div>


<p>The beauty of using the later over the former is that all the heavy lifting has been done for us. By placing the link in your template, you can take advantage of all the available features. We <a rel="noreferrer noopener" href="https://blog.finxter.com/how-i-created-charts-using-highcharts-js-in-django-web-application/" data-type="post" data-id="1529193" target="_blank">have already demonstrated</a> how to display charts using <code>Highcharts.js</code> in a Django web application.</p>



<p>In this tutorial, we will pay attention to <code>Charts.js</code>. Specifically, we will learn:</p>



<ol class="wp-block-list" type="1">
<li>Another way to populate the database other than the ones mentioned while learning how to do so with <code>Highcharts.js</code></li>



<li>How to query the database to display the data structured in such a way that <code>Charts.js</code> can understand.</li>



<li>How to display both bar chart and pie chart</li>
</ol>



<h2 class="wp-block-heading">The Model</h2>



<p>For this project, we will use the data from Kaggle<sup>1</sup> that shows the richest people in the world as of 2022. The data contains several columns but we are only interested in just a few of them. Let us create a database model for the dataset.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from django.db import models

GENDER = (
    ('M', 'Male'),
    ('F', 'Female'),
)

class Richest(models.Model):
    name = models.CharField(max_length=100)
    gender = models.CharField(max_length=1, choices=GENDER)
    net_worth = models.IntegerField()
    country = models.CharField(max_length=100)
    source = models.CharField(max_length=100)

    def __str__(self):
        return self.name
</pre>



<p>The model contains names of the richest people in the world, their net worth, country of origin and their source of wealth.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="720" height="405" src="https://blog.finxter.com/wp-content/uploads/2023/08/image-34.png" alt="" class="wp-image-1547023" srcset="https://blog.finxter.com/wp-content/uploads/2023/08/image-34.png 720w, https://blog.finxter.com/wp-content/uploads/2023/08/image-34-300x169.png 300w" sizes="auto, (max-width: 720px) 100vw, 720px" /></figure>
</div>


<h2 class="wp-block-heading">Populating the database</h2>



<p>In the previous tutorial project on creating a chart using <code>Highcharts.js</code>, I showed you one of the ways to populate a database. I wrote a script from the Django shell to populate the database. In this tutorial, we will learn a different method.</p>



<p>We will use Django’s <code>BaseCommand</code> class to create a custom management command that populates the database using the dataset.</p>



<p>Start by creating new folders inside the app folder. For example, assuming the name of your Django app is charts and is created in your current directory, run the following in your Ubuntu terminal:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">mkdir charts/management/commands -p</pre>



<p>The <code>p</code> flag makes it possible to create a nested folder in one command. Inside the <code>commands</code> folder, create a new file named <code>populate_db.py</code>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">nano charts/management/commands/populate_db.py</pre>



<p>let’s first import the required modules:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from django.core.management.base import BaseCommand
from charts.models import Richest
import csv
import math
</pre>



<p><code>BaseCommand</code>&nbsp;is a class provided by Django that serves as the base class for writing custom management commands. Management commands are scripts that can be run from the command line to perform various tasks related to your Django app.</p>



<p>The&nbsp;<code>BaseCommand</code>&nbsp;class provides several useful methods and attributes that make it easy to write custom management commands. When you create a custom management command by subclassing&nbsp;<code>BaseCommand</code>, you need to override the&nbsp;<code>handle</code>&nbsp;method to define the behavior of your command.</p>



<p>The&nbsp;<code>handle</code>&nbsp;method is called when the command is executed, and it receives any command-line arguments passed to the command as keyword arguments.</p>



<p>In addition to the&nbsp;<code>handle</code>&nbsp;method, the&nbsp;<code>BaseCommand</code>&nbsp;class provides several other methods and attributes that you can use when writing custom management commands.</p>



<p>For example, as we shall see, you can use the&nbsp;<code>add_arguments</code>&nbsp;method to define custom command-line arguments for your command, and you can use the&nbsp;<code>stdout</code>&nbsp;and&nbsp;<code>stderr</code>&nbsp;attributes to write output to the Ubuntu terminal.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">class Command(BaseCommand):
    help = 'Populate the database using a CSV file'

    def add_arguments(self, parser):
        parser.add_argument('forbes_2022_billionaires.csv', type=str, help='The path to the CSV file')

    def handle(self, *args, **options):
        csv_file = options['forbes_2022_billionaires.csv']

        with open(csv_file, 'r') as f:
            reader = csv.DictReader(f)
            for row in reader:
                skip_row = False
                for value in row.values():
                    try:
                        if math.isnan(float(value)):
                            skip_row = True
                            break
                    except ValueError:
                        pass
                if skip_row:
                    continue
                net_worth = int(float(row['finalWorth']))
                obj, created = Richest.objects.get_or_create(
                    name=row['personName'],
                    gender=row['gender'],
                    net_worth=net_worth,
                    country=row['countryOfCitizenship'],
                    source=row['source']
                 )

        self.stdout.write(self.style.SUCCESS('Successfully populated the database'))
</pre>



<p>We define a new&nbsp;<code>Command</code>&nbsp;class that inherits from&nbsp;<code>BaseCommand</code>.</p>



<p>In the <code>add_arguments</code> method, we define a new command-line argument called <code>csv_file</code> that specifies the path to the CSV file. In the <code>handle</code> method, we <a href="https://blog.finxter.com/read-a-csv-file-to-a-pandas-dataframe/" data-type="post" data-id="440655" target="_blank" rel="noreferrer noopener">read the data from the CSV file</a> and use a conditional statement to check if any of the values in the current row are NaN.</p>



<p>If any value is NaN, we use the&nbsp;<code>continue</code>&nbsp;statement to skip this row and move on to the next one. Otherwise, we use the&nbsp;<code>get_or_create</code>&nbsp;method to add the data to the database. Finally, we use the&nbsp;<code>self.stdout.write</code>&nbsp;method to print a success message.</p>



<p>We use a <a rel="noreferrer noopener" href="https://blog.finxter.com/how-to-write-a-nested-for-loop-in-one-line-python/" data-type="post" data-id="11859" target="_blank">nested loop</a> to iterate over each value in the row. For each value, we use a try-except block to try to convert the value to a float and check if it is NaN. If a <code>ValueError</code> exception occurs, we catch it and ignore it using <a href="https://blog.finxter.com/python-pass-statement/" data-type="post" data-id="29709" target="_blank" rel="noreferrer noopener">the <code>pass</code> statement</a>.</p>



<p>If any value in the row is NaN, we set the&nbsp;<code>skip_row</code>&nbsp;variable to&nbsp;<code>True</code>&nbsp;and use the&nbsp;<code>break</code>&nbsp;statement to exit the inner loop. After the inner loop completes, we use an if statement to check if the&nbsp;<code>skip_row</code>&nbsp;variable is&nbsp;<code>True</code>. If it is, we use the&nbsp;<code>continue</code>&nbsp;statement to skip this row and move on to the next one.</p>



<p>However, a problem arises from the dataset. The <code>net_worth</code> field is an <code>IntegerField</code>. Whereas, the data type of the <code>finalWorth</code> column is float. To avoid errors, we first convert the value of the <code>net_worth</code> field in the current row to a float using the <code>float</code> function, and then convert it to an integer using the <code>int</code> function. We then assign this integer value to the <code>net_worth</code> field of the <code>Richest</code> model instance using the <code>get_or_create</code> method.</p>



<p>Make sure you have the <code>forbes_2022_billionaires.csv</code> file downloaded and placed in your current directory. Then, run the command we defined from the command line using the <code>manage.py</code> script like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">python3 manage.py populate_db forbes_2022_billionaires.csv</pre>



<p>Afterward, a success message will be displayed. We have populated our database. Open the admin interface to see it.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="720" height="405" src="https://blog.finxter.com/wp-content/uploads/2023/08/image-35.png" alt="" class="wp-image-1547026" srcset="https://blog.finxter.com/wp-content/uploads/2023/08/image-35.png 720w, https://blog.finxter.com/wp-content/uploads/2023/08/image-35-300x169.png 300w" sizes="auto, (max-width: 720px) 100vw, 720px" /></figure>
</div>


<h2 class="wp-block-heading">Displaying charts using Charts.js</h2>



<p>Make sure you have included the <code>Charts.js</code> library in your template by adding the following script tag to the <code>&lt;head></code> section of your HTML file:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;script src="https://cdn.jsdelivr.net/npm/chart.js">&lt;/script></pre>



<p>Next, add a <code>&lt;canvas></code> element to your template where you want to display the chart. Give this element an id so you can reference it in your JavaScript code.</p>



<p>Here’s an example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;canvas id="myChart">&lt;/canvas></pre>



<p>In this demonstration, we will query the database to:</p>



<ol class="wp-block-list" type="1">
<li>Calculate total net worth of each country</li>



<li>Get the top 10 richest people in the world</li>



<li>Get the top 10 richest women in the world</li>



<li>Get the distribution of wealth by gender</li>
</ol>



<p>We will also include a pie chart. You can always check the source code for more details.</p>



<h2 class="wp-block-heading">Displaying the total net worth of each country</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from django.shortcuts import render
from django.db.models import Sum
from .models import Richest

def TotalNetWorth(request):
    # Query the database to get the data
    data = Richest.objects.values('country').annotate(total_net_worth=Sum('net_worth')).order_by('-total_net_worth')

    # Prepare the data for the chart
    chart_data = []
    for item in data:
        chart_data.append({
            'country': item['country'],
            'total_net_worth': item['total_net_worth']
        })

    # Render the template with the chart data
    return render(request, 'total_net_worth.html', {'chart_data': chart_data})
</pre>



<p>We group the data by country using the <code>values</code> method, and using the <code><a href="https://blog.finxter.com/how-i-created-charts-using-highcharts-js-in-django-web-application/" data-type="post" data-id="1529193" target="_blank" rel="noreferrer noopener">annotate</a></code> method, we calculate the total net worth of each country. </p>



<p>Next, we prepare the data for the chart by creating a new list called <code>chart_data</code> and appending a dictionary for each item in the query result. </p>



<p>Each <a href="https://blog.finxter.com/python-dictionary/" data-type="post" data-id="5232" target="_blank" rel="noreferrer noopener">dictionary</a> contains two keys: <code>'country'</code> and <code>'total_net_worth'</code>, which represent the country and its total net worth, respectively.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;script>
    var ctx = document.getElementById('myChart').getContext('2d');
    var chart = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: {{ chart_data|safe }}.map(item => item.country),
            datasets: [{
                label: 'Total Net Worth',
                data: {{ chart_data|safe }}.map(item => item.total_net_worth),
                backgroundColor: 'rgba(54, 162, 235, 0.2)',
                borderColor: 'rgba(54, 162, 235, 1)',
                borderWidth: 1	
            }]
        },
        options: {
            scales: {
                y: {
                    beginAtZero: true
                }
            }
        }
    });
&lt;/script>
</pre>



<p>Here, we create a new <code>Chart</code> object and pass it the context of the <code>&lt;canvas></code> element and an options object that specifies the type of chart and its data. </p>



<p>We use the <code>chart_data</code> variable passed as context to populate the chart with data. </p>



<p>Then, we use the <code>map</code> method to extract the country names and total net worth values from the <code>chart_data</code> and assign them to the <code>labels</code> and <code>data</code> properties of the chart’s datasets.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="720" height="405" src="https://blog.finxter.com/wp-content/uploads/2023/08/image-36.png" alt="" class="wp-image-1547027" srcset="https://blog.finxter.com/wp-content/uploads/2023/08/image-36.png 720w, https://blog.finxter.com/wp-content/uploads/2023/08/image-36-300x169.png 300w" sizes="auto, (max-width: 720px) 100vw, 720px" /></figure>
</div>


<p>Check out the source code for a demonstration of a pie chart. It’s almost the same.</p>



<h2 class="wp-block-heading">Displaying the top ten richest people in the world</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def TopTenRichest(request):
    # Query the database to get the data
    data = Richest.objects.order_by('-net_worth')[:10]

    # Prepare the data for the chart
    chart_data = []
    for item in data:
        chart_data.append({
            'name': item.name,
            'net_worth': item.net_worth
        })

    # Render the template with the chart data
    return render(request, 'top_ten_richest.html', {'chart_data': chart_data})
</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="720" height="405" src="https://blog.finxter.com/wp-content/uploads/2023/08/image-37.png" alt="" class="wp-image-1547028" srcset="https://blog.finxter.com/wp-content/uploads/2023/08/image-37.png 720w, https://blog.finxter.com/wp-content/uploads/2023/08/image-37-300x169.png 300w" sizes="auto, (max-width: 720px) 100vw, 720px" /></figure>
</div>


<p>The following code shows how to display a pie chart using <code>Charts.js</code>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
    type: 'pie',
    data: {
        labels: {{ chart_data|safe }}.map(item => item.name),
        datasets: [{
            label: 'Net Worth',
            data: {{ chart_data|safe }}.map(item => item.net_worth),
            backgroundColor: [
                'rgb(255, 99, 132)',
                'rgb(54, 162, 235)',
                'rgb(255, 205, 86)',
                'rgb(75, 192, 192)',
                'rgb(153, 102, 255)',
                'rgb(255, 159, 64)',
                'rgb(255, 99, 132)',
                'rgb(54, 162, 235)',
                'rgb(255, 205, 86)',
                'rgb(75, 192, 192)'
            ],
            hoverOffset: 4
        }]
    },
    options: {
        title: {
            display: true,
            text: 'Top Ten Richest People'
        }
    }
});
</pre>



<p>This code creates a new <code>Chart</code> object and sets its type to <code>'pie'</code>. The data for the chart is taken from the <code>chart_data</code> variable that was passed to the template from <code>TopTenRichest</code> view function. </p>



<p>The <code>labels</code> for the chart are set to the names of the richest people, and the data for the chart is set to their net worths.</p>



<p>The source code also contains the bar chart example.</p>



<h2 class="wp-block-heading">Displaying the top ten richest women</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def TopRichestWomen(request):
    data = Richest.objects.filter(gender='F').order_by('-net_worth')[:10]
    names = [item.name for item in data]
    net_worths = [item.net_worth for item in data]
    return render(request, 'top_richest_women.html', {
        'names': names,
        'net_worths': net_worths
    })
</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="720" height="405" src="https://blog.finxter.com/wp-content/uploads/2023/08/image-38.png" alt="" class="wp-image-1547031" srcset="https://blog.finxter.com/wp-content/uploads/2023/08/image-38.png 720w, https://blog.finxter.com/wp-content/uploads/2023/08/image-38-300x169.png 300w" sizes="auto, (max-width: 720px) 100vw, 720px" /></figure>
</div>


<h2 class="wp-block-heading">Distribution of wealth by gender</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def WealthByGender(request):
    # Query the database to get the total net worth for each gender
    male_net_worth = Richest.objects.filter(gender='M').aggregate(Sum('net_worth'))['net_worth__sum']
    female_net_worth = Richest.objects.filter(gender='F').aggregate(Sum('net_worth'))['net_worth__sum']

    # Prepare the data for the chart
    data = {
        'labels': ['Male', 'Female'],
        'datasets': [{
            'data': [male_net_worth, female_net_worth],
            'backgroundColor': ['#36A2EB', '#FF6384']
        }]
    }

    # Render the chart using the Chart.js library
    return render(request, 'wealth_by_gender.html', {'data': data})
</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="720" height="405" src="https://blog.finxter.com/wp-content/uploads/2023/08/image-39.png" alt="" class="wp-image-1547034" srcset="https://blog.finxter.com/wp-content/uploads/2023/08/image-39.png 720w, https://blog.finxter.com/wp-content/uploads/2023/08/image-39-300x169.png 300w" sizes="auto, (max-width: 720px) 100vw, 720px" /></figure>
</div>


<p>And this is the pie chart. Check the source code for more details:</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>In this project tutorial, we have learned various ways to query our database, structure the data and displayed them using <code>charts.js</code>, a JavaScript library for data visualization. We saw how Django interacts with <code>charts.js</code> to display charts on a template.</p>



<p>We also learned another way to populate the database by using Django’s <code>BaseCommand</code> class. Due to the nature of the dataset, we were restricted to only bar and pie charts. However, we can apply the process to create other charts.</p>



<p>Use the knowledge you learned to integrate charts in your Django web application.</p>



<ul class="wp-block-list">
<li><a rel="noreferrer noopener" href="https://www.kaggle.com/datasets/prasertk/forbes-worlds-billionaires-list-2022?resource=download" target="_blank">Forbes World&#8217;s Billionaires List 2022 | Kaggle</a></li>
</ul>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="https://blog.finxter.com/the-math-of-becoming-a-millionaire/" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="1024" height="618" src="https://blog.finxter.com/wp-content/uploads/2023/08/image-40-1024x618.png" alt="" class="wp-image-1547035" srcset="https://blog.finxter.com/wp-content/uploads/2023/08/image-40-1024x618.png 1024w, https://blog.finxter.com/wp-content/uploads/2023/08/image-40-300x181.png 300w, https://blog.finxter.com/wp-content/uploads/2023/08/image-40-768x463.png 768w, https://blog.finxter.com/wp-content/uploads/2023/08/image-40.png 1363w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>
</div>


<p class="has-base-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Recommended</strong>: <a href="https://blog.finxter.com/the-math-of-becoming-a-millionaire/" data-type="URL" data-id="https://blog.finxter.com/the-math-of-becoming-a-millionaire/" target="_blank" rel="noreferrer noopener">The Math of Becoming a Millionaire in 13 Years</a></p>
<p>The post <a href="https://blog.finxter.com/how-i-created-charts-using-charts-js-in-django-web-application/">How I Created Charts Using Charts.js in Django Web Application</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: blog.finxter.com @ 2026-06-07 09:37:08 by W3 Total Cache
-->