Created
June 8, 2024 16:15
-
-
Save hartwork/9e7593e25664477efa4c06fd38203f78 to your computer and use it in GitHub Desktop.
Plot 1% loss/gain per day for one year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2024 Sebastian Pipping <[email protected]> | |
# Licensed under the MIT license | |
import math | |
import pylab | |
from matplotlib import pyplot | |
START = 100 | |
DAYS = 365 | |
LOSS = [START * 0.99 ** i for i in range(DAYS)] | |
GAIN = [START * 1.01 ** i for i in range(DAYS)] | |
fig = pyplot.figure() | |
SUBPLOT_ROWS = 2 | |
SUBPLOT_COLS = 1 | |
for subplot_index, (yscale, ylim) in enumerate(( | |
('linear', [0, 500]), | |
('log', [0, 10 ** math.ceil(math.log10(GAIN[-1]))]), | |
)): | |
sub_plot = fig.add_subplot(SUBPLOT_ROWS, SUBPLOT_COLS, subplot_index + 1) | |
sub_plot.title.set_text(f'{yscale} Y scale') | |
sub_plot.set_yscale(yscale) | |
sub_plot.set_xlim([0, DAYS]) | |
sub_plot.set_ylim(ylim) | |
sub_plot.plot(LOSS, color='red') | |
sub_plot.plot(GAIN, color='blue') | |
fig.subplots_adjust(hspace=0.3) # stop second title from overlapping | |
pylab.show() |
Author
hartwork
commented
Jun 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment