This is an old birthday gift for a special person. It was the first time I tried to plot something using python, and I wasn’t very familiar with matplotlib, so I used the turtle library. import turtleimport timedef auguri(): colors = [‘blue’, ‘red’, ‘green’, ‘yellow’, ‘orange’, ‘purple’] turtle.pensize(5) turtle.bgcolor(‘black’) turtle.speed(1000) for x in range(360): turtle.pencolor(colors[x […]
Tag: python
Plotting 3D Lines
In Python as you know there’s the option of plotting 3D graphs, so why not fully exploiting such possibilities? In this example I will show a sort of an irregular spiral figure. import matplotlib as mplimport numpy as npimport matplotlib.pyplot as pltmpl.rcParams[‘legend.fontsize’] = 10fig = plt.figure()ax = fig.gca(projection=’3d’)theta = np.linspace(-4 * np.pi, 4 * np.pi, […]
Very Elegant Image Color Segmentation
Let’s start with this suggestive image of a tree with pink flowers on it. What I want to do is simplifying it to see its main colors. How can I do it? Well, here some unsupervised learning techniques may come in handy. Clustering the pixels of the image, which are no other than points in […]
Recursive Solution To A Nice Problem
There is a frog jumping on lily pads labeled with natural numbers. It’s on the 2015th lily pad and can either go one step forward or backwards, except if it at any time is on a lily pad divisible by 6 it has to go forward. How many 15-steps paths are possible? The problem is […]
Plotting Epicycloids
An epicycloid is the figure that a fixed point of a circle draws when the circle rotates on the circumference of another one. How to plot such things in Python? There is a trick: such figures depend on the ratio of the still circle’s and the rotating circle’s radius. Let’s say we have an integer […]
Happy Birthday Mom
I Made this nice plot for my mother’s birthday (which is today, 4th December) and I thought it would be nice to share it. import numpy as npimport matplotlib.pyplot as pltdef heart_plotter(precision): t = np.linspace(0, 60, precision) X = 1/100*(-t**2 + 40*t + 1200)*np.sin(t/90) Y = 1/100*(-t**2 + 40*t + 1200)*np.cos(t/60) Y_1 = 1/100*(-t**2 + […]
A Python Rubik’s Cube Solver: Part 1
Finally, I was able to get my own GitHub account, which you can find at https://github.com/mattiagiuri, and my first repository is one containing my latest project: a Rubik’s cube solver in Python. If you want, you can check it out and have fun with your Rubik’s cube solving tasks. How does it work? First, I […]
A Very Notorious Problem, But In 3D
I’ve already made an article on the 2D version of this problem, if you want to check it out before this one, you can visit https://www.mattiagiuri.com/2020/04/21/a-very-notorious-problem/. Now, the 3D version says: if you have 3 reals x, y, z chosen randomly between 0 and 1, what’s the probability that It’s important to notice that any […]
Lorenz Attractor In Python Graphed
In my school course ‘Python For Physics’ we had to choose among some topics to study and implement in Python, and I and my colleague decided to go for the Lorenz Attractor equations. The Lorenz System is a system of differential equations which generates a very chaotic plot, where chaotic means that little variations may […]
Hearts Equations In Math
In this article, I’ll show you five different equations you can use to plot your own heart. Let’s start with the simplest: I think this is the most classic of the five I’m going to show you. If you prefer one which is a little bit thinner, there is this one: On the other hand, […]