Skip to content

Commit

Permalink
add function for plotting en scales
Browse files Browse the repository at this point in the history
  • Loading branch information
lmmentel committed Nov 6, 2024
1 parent e1e6eeb commit 780eb52
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions mendeleev/vis/plotly.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
from plotly.graph_objs.layout import Shape, Annotation
from pandas.api.types import is_float_dtype

Expand Down Expand Up @@ -162,3 +163,29 @@ def periodic_table_plotly(
)

return fig


def plot_scale(data: pd.DataFrame, scale: str):
"""Plot an electronegativity scale
Args:
data: DataFrame with the electronegativity data, obtained from :func:`fetch.fetch_electronegativities`
scale: Electronegativity scale to plot
"""
fig = px.scatter(
data,
y=scale,
template="plotly_white",
height=600,
width=1400,
text="symbol",
title=f"{scale}'s Electronegativity",
)
fig.update_traces(
textposition="top center",
textfont={"size": 10},
marker={"size": 8, "color": "#0081a7"},
)
fig.update_layout(font={"size": 12})
fig.update_xaxes(title_text="Atomic Number", zeroline=False, range=[0, 119])
return fig

0 comments on commit 780eb52

Please sign in to comment.