Open talledodiego opened 2 months ago
Thanks for drafting this, @talledodiego 😃 I totally see your point that it is not straightforward to implement some general methods that could fit all use cases. However, I think what you demonstrate is a good first step.
We could consider an option where we provide some meaningful simple methods that return plots that can be further customized by the user. This way, and when having already a section defined, a user can do a calculation, and get a plot in just two lines of code. For the special case with 3d plot of the interaction domain, we are perhaps targeting an expert user that in any case will implement his/her own plotting methods?
Or we could consider another option where we create a separate library which is only responsible for plotting the contents of the result classes in structuralcodes. This way we separate the concerns and build further on the initial idea that structuralcodes is mainly a backend for calculations, and other libraries or applications are responsible for the frontend.
Or we could consider another option where we create a separate library which is only responsible for plotting the contents of the result classes in structuralcodes. This way we separate the concerns and build further on the initial idea that structuralcodes is mainly a backend for calculations, and other libraries or applications are responsible for the frontend.
I think I agree with this point. I am in favour of splitting responsibilities to several packages. Now that you mention it, for instance OpenSeesPy is just a computation backend. For visualizing there is vfo.
Stated that, I agree with your idea of having a basic plot with just a line of code. And indeed is the idea of implementation where all arguments are optional. Therefore the user can just write:
res_1 = section.section_calculator.calculate_nm_interaction_domain(theta=0)
res_2 = section.section_calculator.calculate_nm_interaction_domain(theta=0+np.pi)
fig, ax = res_1.get_2d_plot()
fig, ax = res_2.get_2d_plot(ax=ax)
and obtain a basic diagram. Anyhow there are some issues that the basic user would like to handle, like scaling, coloring of lines, label names, etc.
Thanks for the clarification. This now grows into a larger question related to what the scope of structuralcodes should really be, and for the sake of maintenance I think factoring plotting out into a separate library makes most sense. Let us bring this up in a discussion with the rest of the group in our next meeting.
Meanwhile, let us keep the PR open.
This is just a first attempt.
The following code creates the related plot:
Even this simple case it shows that is somehow complicated to do something that covers all common cases. For instance:
which produces the following plot:
For dealing with this issue I created a function
get_2d_plot
and a functionget_3d_plot
that contains a 3d version of it. Alternatively we could create a singleget_plot
function and ask instead ofvertical_axis
andhorizontal_axis
the argumentsx_axis
andy_axis
adding anOptional
z_axis
by default set to None. If specified it will create the 3d plot, otherwise the 2d plot.In this way we can create for instance the following plot:
producing the following picture:
which produces the following picture:
for this last problem maybe we can insert
scale_x
andscale_y
arguments to the functionget_plot
?What do you think @mortenengen ?