Set a minimum level in contour plots

Sh_166
Wed, 07 Aug 2024 04:12:58 +0000
Visualization

I want to make a contour plot but I only want specific contours - or levels above a certain range.

MWE:

Pkg.add("Symbolics")
Pkg.add("Plots")
Pkg.add("LaTeXStrings")
Pkg.add("Measures")
Pkg.add("PlotThemes")

using Symbolics, Plots, LaTeXStrings, Measures, PlotThemes

mₕ = 125
v = 246
mₜ = 172.76
Nₜ = 3

k = (pi*mₕ*v)
s = 1 - (Nₜ/(3*k^2))mₜ^4

f(X, Y) = (100/(3*s*k^2))*(((1-(X/Y)^2)^3))*(Y^4)

X = range(0, 200, length=1000)
Y = range(0, 500, length=2000)
Z = @. f(X', Y)

contour(X, Y, Z)

This function takes values in a broad range and the output from this code is this:

It is clear from the colour bar that the contours chosen to be plotted are extremely small - what I want, however, are contours with z = 5, 10, 30, 50, 70, 100 - so, I don’t really need these particular contours.

However, I am not sure what exactly to do here to get what I want. As an example of what I want to plot, this is the same function plotted in Mathematica:

The code for this is:

f[x_, y_] := ((1/(3*Pi^2*125^2*246^2))*
    y^4*(1 - x^2/y^2)^3)/(1 - ((172.76)^4)/(Pi^2*125^2*246^2))

ContourPlot[{f[x, y] == 0.05, f[x, y] == 0.1, f[x, y] == 0.3,
  f[x.y] == 0.5, f[x, y] == 0.7, f[x, y] == 1}, {x, 0, 200}, {y, 150,
  480}, Frame -> True, PlotTheme -> "Scientific",
 PlotLegends -> {"5 %", "10 %", "30 %", "50 %", "70 %", "100 %"},
 ContourStyle -> Dashed, GridLines -> Automatic]

Any help would be appreciated!

10 posts - 2 participants