On Saturday, December 14, 2024 at 4:46:59 AM UTC-6 Edward K. Ream wrote:

On second thought, the title of this thread is misguided.


I have spent the last week coming up to speed on all the fabulous math 
tools and websites out there.

This morning I finally got around to writing my first matplotlib program. 
See the Postscript. 
This exercise has been a ton of fun. execute-script just works!

For me, Leo *is *the perfect platform for running Matplotlib programs.
The more I use Jupyter, the less I like it, so the title of this thread 
seems about right :-)

Edward

P.S. Here is my first plot:

import matplotlib.pyplot as plt
import numpy as np

# Use a monospace font for 
plt.rcParams["font.family"] = 'DejaVu Sans Mono'

a, b = [], []
for x in range(-50,50):
    y=x**2
    a.append(x)
    b.append(y)

fig= plt.figure()
fig.suptitle('Parabola with Tangents')
axes=fig.add_subplot()
axes.plot(a,b)

# Cut the tangent lines off at y = 0
plt.ylim(bottom=0)
color = iter(plt.cm.rainbow(np.linspace(0, 1, 6)))
for i, x in enumerate(range(-50, 60, 20)):
    if x == 0:
        continue
    y = x**2
    slope = 2 * x
    x_y_s = f"({x:3}, {y})"
    label = f"{x_y_s:<11} slope: {slope:4}, x-intercept: {x - y/slope:>5}"
    plt.axline((x, y), slope=slope, label=label, c=next(color))
axes.legend()
fig.canvas.manager.window.move(50,50)  # Move the window.
plt.show()

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/7dac913d-b012-4e87-900a-1ad251df3ebcn%40googlegroups.com.

Reply via email to