JuliaPhysics / SolidStateDetectors.jl

Solid state detector field and charge drift simulation in Julia
Other
82 stars 32 forks source link

There is somethong wrong with plot #352

Closed zql2021 closed 1 year ago

zql2021 commented 1 year ago

Hello,I'm a beginner in SolidStateDetectors, and I've installed the SolidStateDetectors package and Plots package using the following commands:

using Pkg
pkg"add SolidStateDetectors"
pkg"add Plots"

However, I encountered an issue when trying to create a plot with the error message "MethodError: no method matching mesh(::SolidStateDetectors.ConstructiveSolidGeometry.Polygon{4, Float64}, ::Int32)." Here is my test code:

using SolidStateDetectors
import SolidStateDetectors.ConstructiveSolidGeometry as CSG
using Plots
T = Float64
#
path_to_example_primitives_config_files = joinpath(dirname(dirname(pathof(SolidStateDetectors))), "examples", "example_primitive_files")
example_primitives_config_filenames = readdir(path_to_example_primitives_config_files)

cfn = joinpath(path_to_example_primitives_config_files, "Box.yaml")
print(open(f -> read(f, String), cfn))
box = CSG.Geometry(T, cfn)
plot(box)

Here are the detailed error info

MethodError: no method matching mesh(::SolidStateDetectors.ConstructiveSolidGeometry.Polygon{4, Float64}, ::Int32)
Closest candidates are:
  mesh(::SolidStateDetectors.ConstructiveSolidGeometry.AbstractSurfacePrimitive{T}, !Matched::Int64) where T
   @ SolidStateDetectors [~/.julia/packages/SolidStateDetectors/hbnqY/src/ConstructiveSolidGeometry/plotting/Meshing.jl:18](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/SolidStateDetectors/hbnqY/src/ConstructiveSolidGeometry/plotting/Meshing.jl:18)
  mesh(::SolidStateDetectors.ConstructiveSolidGeometry.AbstractSurfacePrimitive{T}, !Matched::Int64, !Matched::Int64) where T
   @ SolidStateDetectors [~/.julia/packages/SolidStateDetectors/hbnqY/src/ConstructiveSolidGeometry/plotting/Meshing.jl:25](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/SolidStateDetectors/hbnqY/src/ConstructiveSolidGeometry/plotting/Meshing.jl:25)

Stacktrace:
  [1] macro expansion
 @[~/.julia/packages/SolidStateDetectors/hbnqY/src/ConstructiveSolidGeometry/plotting/SurfacePrimitives/SurfacePrimitives.jl:21](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/SolidStateDetectors/hbnqY/src/ConstructiveSolidGeometry/plotting/SurfacePrimitives/SurfacePrimitives.jl:21) [inlined]
  [2] macro expansion
    @ [~/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl:340](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl:340) [inlined]
  [3] macro expansion
   @[~/.julia/packages/SolidStateDetectors/hbnqY/src/ConstructiveSolidGeometry/plotting/SurfacePrimitives/SurfacePrimitives.jl:17](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/SolidStateDetectors/hbnqY/src/ConstructiveSolidGeometry/plotting/SurfacePrimitives/SurfacePrimitives.jl:17) [inlined]
  [4] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, s::SolidStateDetectors.ConstructiveSolidGeometry.AbstractSurfacePrimitive)
    @ SolidStateDetectors.ConstructiveSolidGeometry [~/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl:300](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl:300)
  [5] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline [~/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl:38](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl:38)
  [6] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline [~/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl:72](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl:72)
  [7] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
    @ Plots [~/.julia/packages/Plots/sxUvK/src/plot.jl:223](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/Plots/sxUvK/src/plot.jl:223)
  [8] #plot#188
    @ [~/.julia/packages/Plots/sxUvK/src/plot.jl:102](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/Plots/sxUvK/src/plot.jl:102) [inlined]
  [9] plot(args::Any)
    @ Plots [~/.julia/packages/Plots/sxUvK/src/plot.jl:93](https://file+.vscode-resource.vscode-cdn.net/home/zql/Documents/Seafile/work_zql/CIGAR-PSS/~/.julia/packages/Plots/sxUvK/src/plot.jl:93)

I'm running this code in a Jupyter Notebook in Visual Studio Code. I would appreciate any suggestions you can provide to help me resolve this issue. Thank you very much.

fhagemann commented 1 year ago

I cannot reproduce your error and I obtain the desired plot: image

Which version of Plots and SolidStateDetectors are you using?

(run ]st Plots and ]st SolidStateDetectors)