Skip to content

Creates tooltip for nodes and elements with OpenSeesPy and mplcursors.

License

Notifications You must be signed in to change notification settings

ajayakhatri/OpsTooltip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpsTooltip

Creates tooltip for nodes and elements with OpenSeesPy and mplcursors.

3D demo of OpsTooltip 2D demo of OpsTooltip

Description

  • This script enables users to obtain information about nodes and elements by hovering over them. Initially, it generates a JSON file containing information about geometry i.e. nodes and elements. Subsequently, the script reads the node and element data from the JSON file. Finally, it utilizes mplcursors to create tooltips, providing insights when users hover over nodes and elements during visualization.

  • Users can display tooltip for elements and nodes with get_tooltips_for_elements and get_tooltips_for_nodes functions, respectively. In addition, custom texts can be added with add_custom_text function.

  • The script uses Matplotlib's ax object as input, facilitating seamless integration with opsvis (OpenSeesPy postprocessing and plotting module). Examples of 2D and 3D models are given in example2D.py and example3D.py, respectively.

  • For elements, the effective hover range is set to the middle 70% of the element's length to avoid multiple tooltips at the nodes.

# Example
# create a figure
fig = plt.figure()
ax1 = fig.add_subplot(111)

# use ax in plot_model of opsvis
opsv.plot_model(ax=ax1)

# add custom texts
add_custom_text("element", 1, "This is element no.1.")
add_custom_text("node", 3, "This is a fixed support.\n This is node no.3")

# use the previous ax to generate tooltips
get_tooltips_for_elements(ax1)
get_tooltips_for_nodes(ax1)

Note

  • The tooltips are functional when figure is shown in a new window. You can use %matplotlib qt to change default inline display to a windows display in your Jupyter Notebook.
  • You will require mplcursors, openseespy and numpy libraries. You can install these with a pip command pip install -r requirements.txt.

About

Creates tooltip for nodes and elements with OpenSeesPy and mplcursors.

Resources

License

Stars

Watchers

Forks

Languages