## How I Solved a Real-World Problem Using Monte Carlo Simulation

In this project, you are taking the role of a data analyst. Your client, a large retail outlet has been running an affiliate marketing program in an effort to increase its sales. You are tasked to come up with a predictive model to predict how much should be budgeted for sales commission for the following … Read more

## Towards Reverse Engineering Matplotlib Code From Images

I tried a few helpful applications of Google Bards Image Recognition capabilities for coders. I don’t know about you but I often see beautiful plots (e.g., in research papers or data science reports) and wonder how I could recreate them. Well, Google Bard to the rescue! ✅ Reverse Engineer Exponential Plot in 2D First, let’s … Read more

## How to Plot a 3D Normal Distribution in Python?

To create a 3D surface plot of a bivariate normal distribution define two normally distributed random variables x and y, each with its own mean (mu_x, mu_y) and variance (variance_x, variance_y). The random variables are independent,the covariance between x and y is 0. Use the grid of (x, y) pairs to calculate the probability density … Read more

## (Fix) ValueError: Argument Z must be 2-dimensional

Problem Formulation The output when running this code is as follows Warning (from warnings module): File “C:\Users\xcent\Desktop\code.py”, line 10 ax = fig.gca(projection=’3d’) MatplotlibDeprecationWarning: Calling gca() with keyword arguments was deprecated in Matplotlib 3.4. Starting two minor releases later, gca() will take no keyword arguments. The gca() function should only be used to get the current … Read more

## How Do I Make a 3D Waterfall Plot with Colored Heights in Python?

To generate a 3D waterfall plot with colored heights create a 2D sine wave using the NumPy meshgrid() function, then apply a colormap to the heights using Matplotlib’s Normalize function. The plot_surface() function generates the 3D plot, while the color gradient is added using a ScalarMappable object. Here’s a code example for copy and paste: … Read more

## Python 🐍 Put Legend Outside Plot 📈 – Easy Guide

Are you tired of feeling boxed in by your Python plots and ready to break free from the constraints of traditional legend placement? In this guide, I’ll show you how to put legends outside your plot for (click to 🦘 jump): Let’s start with the first! 👇👩‍💻 Matplotlib Put Legend Outside Plot Let’s start with … Read more

## Strategic Investing with Python: Ensuring Your Kids Have \$70k at 21

As a parent, planning for your children’s future is one of the most important things you can do. To ensure they have the best possible start in life, I’ve been looking into ways to invest money to provide them with a lump sum of \$70k when they reach 21. But I don’t want to spend … Read more

## Python Matplotlib Makes Conway’s Game of Life Come Alive

In this article, you’ll learn how to make this beautiful and interesting animation using only Python, NumPy, and Matplotlib — nothing else: 👇 But how does the Game of Life work – and what’s behind the classical visualization anyways? The Game of Life Conway’s Game of Life is a cellular automaton devised by the British … Read more

## How to Return a Plot or Figure in Python Matplotlib?

💬 Question: How can I return a Matplotlib axis, plot, or figure object in Python so I can set some defaults and plot a figure quickly based on those defaults? Basic Solution To return a Matplotlib object from a function, follow these steps: 👇 Create a function my_plot(x, y, …) with arguments to customize your … Read more

## Python Plot Logarithmic Axes — Easy Bitcoin Example

Quick Answer: To print a logarithmic x-axis or y-axis (base 10) without a Matplotlib axis object use plt.xscale(‘log’) or plt.yscale(‘log’). To set different bases or switch back to a linear scale, use {“linear”, “log”, “symlog”, “logit”} or set the basex and basey arguments (e.g., plt.yscale(‘log’, basey=2) for log base 2). Next, we’ll have a look … Read more

## Python Time Series Forecast – A Guided Example on Bitcoin Price Data

A Time Series is essentially a tabular data with the special feature of having a time index. The common forecast task is ‘knowing the past (and sometimes the present), predict the future’. This task, taken as a principle, reveals itself in several ways: in how to interpret your problem, in feature engineering, and in which … Read more

## Plotting Vector Fields and Gradients for ANN Gradient Descent

👉 This is a follow-up article to Gradient Descent in Neural Nets – A Simple Guide to ANN Learning – Finxter, where a lightweight introduction to Gradient Descent is given. In this article, you will learn how to produce the graphs in that article, especially the vector fields! Data visualization is an enlightening task in … Read more