r/Python • u/dhaitz • Apr 04 '20
I Made This Matplotlib add-on to make Tron-style plots: github.com/dhaitz/mplcyberpunk
3
u/rafgro Apr 05 '20 edited Apr 05 '20
Love it, implemented on the go: https://imgur.com/BiHNKYq
Small caveat - it kept resetting y axis bottom limit to 0, I fixed it with saving bottom limit before underglow and then setting it back to the saved value after underglow.
edit - switched compressed jpg to better quality png
1
u/dhaitz Apr 05 '20
thanks for the feedback! the y axis reset was already reported on GitHub and should be fixed in the latest version :)
84
u/moodyjack11 Apr 04 '20
github.com/dhaitz/mplcyberpunk just so that there is a clickable link.
4
u/StringCheeseInc Apr 06 '20
If you'd like to recreate this beautiful cosine wave that OP posted, here you are ;>
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import mplcyberpunk
t = np.arange(0, 6.4, 0.1) #time
f = 1 #frequency
amplitudes = np.arange(-10,11, 1)
A = [x * np.cos(f*t) for x in amplitudes] #amplitude
colormap_sect = np.linspace(0, 1, len(amplitudes))
colors = [cm.cool(x) for x in colormap_sect]
plt.rcParams['figure.figsize'] = [6, 4]
plt.style.use("cyberpunk")
plt.xlim(right=6.3)
for i in range(len(A)):
plt.plot(t, A[i], color=colors[i])
mplcyberpunk.make_lines_glow()
plt.show()
101
44
u/Nuclear_Wizard Apr 05 '20
This will go well with VSCode synthwave 84
1
0
Apr 05 '20
[deleted]
6
u/Nuclear_Wizard Apr 05 '20
Careful installing the glow. It corrupted my install and I couldn't install any more extensions until I did a complete wipe π
3
24
15
12
3
2
2
u/RomanRiesen Apr 05 '20
One of my profs made beautiful pink and light-blue r plots.
But this tops it!
2
u/FantasticTor Apr 05 '20
I love this. This is definitely making its way into my next project! :) Thanks!
2
2
2
2
2
2
2
2
10
u/brianruiz123 Apr 05 '20
Super cool! Finally some modern styling.
Just wondering, since the glow effect is made by continously adding additional lines while decreasing alpha value, how does it affect the performance? Does it take a noticable amount of time to output?
Looking forward to using the package on my system and maybe implementing the plots one for a covid dashboard :)