Hi all,
I am able to plot reflection of a curve toward y=x axis. But how to reflect a tangent line that went through a certain point to that curve as well?
I want a tangent line plotted at (d,c).
using Plots, LaTeXStrings, Plots.PlotMeasures, CalculusWithJulia # ignore any warnings
gr()
# Define the x-range explicitly
xrange = 0.0:0.1:23.0
# Define the transform (or anything else like `(x,y) -> (x, -y)` etc.
xyidentity = (x,y) -> (x,y)
xytransform = (x,y) -> (y, x)
function make_fg_plot()
f(x) = log(0.2x) + sin(0.01x^2)
a, b = 0, 2
c = 1
plt = plot(; xtick=:true, xlims = (-5,23), ylims = (-5, 23),
legend = :topleft, bottom_margin=5mm)
plt_tangent = plot(tangent(f,c); linecolor = :red,
legend = :topleft, bottom_margin=5mm)
for (T, attrs) in [(xyidentity, (;label = "", linecolor = :green)),
(xytransform, (;label = "", linecolor = :red))]
# Apply the transformation to all tuples (x, f(x))
transformedPoints = T.(xrange, f.(xrange))
# Make vectors out of the resulting tuples for plotting
newx = first.(transformedPoints)
newy = last.(transformedPoints)
plot!(plt, newx, newy; label="")
#plot!(plt_tangent, newx, newy; label="")
plot!(tangent(f,c), a, b, linecolor = :red, label="")
g(x)=x
plot!(g,linecolor=:green, line=(:dash), label="")
scatter!([1], [f(1)], color = "red1", label="", markersize = 3)
scatter!([f(1)], [1], color = "red1", label="", markersize = 3)
plot!([1,f(1)],[f(1),1], label="", linecolor=:green, line=(:dash))
annotate!([(-2.1,1.5, (L"(d,c)", 7, :black))])
annotate!([(2.1,-2, (L"(c,d)", 7, :black))])
annotate!([(0.5,-3.7, (L"l_{1}", 7, :black))])
annotate!([(-3.4,0.8, (L"l_{2}", 7, :black))])
end
return plt
end
make_fg_plot()