How to Create a Bone of Cylinder with Ellipse with Python?

Hi all,

it’s been long, I have been using Julia for so long almost 1 year, thus I want to try can Python plot better than Julia?

I want to plot the right side of this picture
Capture d’écran_2022-12-27_16-49-32

I have plot the left side with Julia:

using Plots, LaTeXStrings, Plots.PlotMeasures
gr()

f(x) = sqrt(x)

plot(f,0,4, xtick=0:4:4, xlims=(0,6), ylims=(0,3), 
	framestyle=:zerolines, bottom_margin=5mm,
	label=L"y = \sqrt{x}", legend=:topright)

plot!(f,0,5, label="", fill=(0, 0.15, :blue))
plot!(f,2,2.3, label="", fill=(0, 0.35, :blue))

# Annotations
annotate!([(2.12,1.6, (L"△ x", 8, :blue))])
annotate!([(2,-0.1, (L"x_{i}", 8, :blue))])
annotate!([(2.4,-0.1, (L"x_{i+1}", 8, :blue))])

Is Python able to plot the right side? since it seems complex to do so in Julia. Thanks before.

I don’t see any obvious reason why you couldn’t plot that using Python. What have you tried so far? I would recommend looking into a package like matplotlib, which can handle some pretty complicated plots.

Thanks for the reply, I try LaTeX instead for this.

Sympy seems to have aplotting package layered on top of mapplotlib,
which might make expressing the curves easier.

There’s both oriented to plotting concrete values, so you’d want to
strip out the axis tick marks for a diagram-like plot shown in the OP’s
example figure.

Cheers,
Cameron Simpson cs@cskk.id.au