Try to draw a life curve with python

As the title says.

The life curve is a time-series review of your own experiences. It is plotted with the x-axis as age and the y-axis as motivation (happiness, fulfillment).

Next, pay attention to where the y-axis goes up and down. By repeating why this happened, you can understand your essential values.

To use the code described, modify the data of x and y according to your own experience. Look for the order in which a graph such as "Oh, yeah, like this" is output.

lifeCurve


import numpy as np
import matplotlib.pyplot as plt

x = np.array([15.0, 16.5, 18.0, 21, 24.0, 25, 26, 27, 28, 29, 30, 33, 35, 37, 45, 53, 62])
y = np.array([15.0, 10.0, 20.0, 30, 24.0, 20, 15, 12, 10, 18, 25, 40, 50, 100, 70, 80, 120])
xp = np.linspace(min(x), max(x), 1000)

plt.rcParams["font.size"] = 20
fx = np.poly1d(np.polyfit(x, y, 6)) #← The order is now 6. Adjust here.
fig, ax = plt.subplots(figsize=(20,10))
ax.plot(xp, fx(xp), '-', color='blue')
ax.scatter(x, y, color='deepskyblue', s=32)
ax.axhline([0], color='black')
ax.set_xlim(min(x), None)
ax.set_ylim(0, 1.2*max(y))
ax.set_ylabel('Motivation Level')
ax.set_xlabel('My age')

color = '#1e90ff'
p1 = np.linspace(20, 23)
ax.fill_between(p1, fx(p1), 0, facecolor=color, alpha=0.5)
p2 = np.linspace(28, 40)
ax.fill_between(p2, fx(p2), 0, facecolor=color, alpha=0.5)
p3 = np.linspace(50, 60)
ax.fill_between(p3, fx(p3), 0, facecolor=color, alpha=0.5)
fig.savefig('./data/img/lifeCurve.png'))

lifeCurve.png

Recommended Posts

Try to draw a life curve with python
Try to draw a Bezier curve
Try to make a "cryptanalysis" cipher with Python
Try to make a dihedral group with Python
[Python] How to draw a line graph with Matplotlib
Try to make a command standby tool with python
I tried to draw a route map with Python
[Python] How to draw a scatter plot with Matplotlib
Try to operate Facebook with Python
Draw Koch curve with Python Turtle
Try to bring up a subwindow with PyQt5 and Python
Try to reproduce color film with Python
Try logging in to qiita with Python
Try HTML scraping with a Python library
Try drawing a map with python + cartopy 0.18.0
Try to create a python environment with Visual Studio Code & WSL
Try to extract a character string from an image with Python3
Try adding a wall to your IFC file with IfcOpenShell python
How to read a CSV file with Python 2/3
Try scraping with Python.
Send a message to LINE with Python (LINE Notify)
[Cloudian # 3] Try to create a new object storage bucket with Python (boto3)
Try to calculate a statistical problem in Python
[Python] Draw a directed graph with Dash Cytoscape
Try to solve the man-machine chart with Python
[Python] How to draw multiple graphs with Matplotlib
I want to make a game with Python
Try to make a capture software with as high accuracy as possible with python (2)
[Python] Draw a Mickey Mouse with Turtle [Beginner]
Try to automatically generate Python documents with Sphinx
Decide to assign a laboratory with Python (fiction)
How to draw a vertical line on a heatmap drawn with Python seaborn
Steps to create a Twitter bot with python
[Python] How to draw a histogram in Matplotlib
Try to solve a set problem of high school math with Python
I want to write to a file with Python
A layman wants to get started with Python
Try to detect fish with python + OpenCV2.4 (unfinished)
Try to solve the traveling salesman problem with a genetic algorithm (Python code)
Try to beautify with Talking Head Anime from a Single Image [python preparation]
WEB scraping with python and try to make a word cloud from reviews
How to convert / restore a string with [] in python
[First API] Try to get Qiita articles with Python
A memo connected to HiveServer2 of EMR with python
Try to make a Python module in C language
Python Ver. To introduce WebPay with a little code.
Try to solve the internship assignment problem with Python
Try to operate DB with Python and visualize with d3
Try embedding Python in a C ++ program with pybind11
[GCP] Try a sample to authenticate users with Firebase
Forcibly draw something like a flowchart with Python, matplotlib
I want to work with a robot in python.
From buying a computer to running a program with python
I tried to automatically generate a password with Python3
A sample to try Factorization Machines quickly with fastFM
[Python] A memo to write CSV vertically with Pandas
A program to write Lattice Hinge with Rhinoceros with Python
Try to automate pdf format report creation with Python
[Python] How to create a 2D histogram with Matplotlib
Live a Haml life with Django1.8 + Jinja2 + hamlish-jinja (Python3)
I want to run a quantum computer with Python