add support for stem plots
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- data-visualization
Línea de trabajo
Comienza examinando el punto de entrada go.Scatter existente y cómo Plotly representa el estilo de los marcadores y las líneas. El issue no especifica archivos del repositorio ni pruebas y deja abierta la elección de la API; se consideraría terminado con una interfaz nativa de stem plot que dibuje stems hasta el eje x, coloque marcadores y admita la personalización de marcadores y líneas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Feature Request: Add support for stem plots
Description:
The stem plot is widely used in MATLAB/Octave/Python(matplotlib.pyplot.stem) to represent discrete data with markers and stems (vertical lines) connecting the data points to the x-axis. It is particularly useful for plotting sampled signals or data that has clear separation along the x-axis.
Currently, Plotly doesn't have a built-in function to replicate the stem plot, but users can manually create similar plots using go.Scatter and adding both lines and markers.
Proposal:
Introduce a native stem plot type that:
- Draws vertical lines from the x-axis to each data point.
- Places a marker on each data point.
- Allows customization of marker and line styles (similar to MATLAB).
Why it’s useful:
- It simplifies the creation of a common plot type in scientific and engineering fields.
- It would improve ease of use for users transitioning from MATLAB/Octave.
Examples:
Below is an example of how users can manually create a stem plot using Plotly’s go.Scatter, but it would be nice if this kind of function could be called as go.Scatter, by passing some parameter to transform in stem plot, or if we could call a function from plotly:
import plotly.graph_objects as go
# Counter for creating unique legend groups if not passed
legendgroup_cnt = 0
# Function to create a stem plot in Plotly
# x: data for the x-axis
# y: data for the y-axis (x and y must have the same number of elements)
# fig: if passed, plots on the given figure, otherwise creates a new one
# marker_symbol: allows changing the marker style (see options at https://plotly.com/python/marker-style/)
# color: the color of the marker and lines
# legendgroup: allows creating a group of legends with the same name
def stem_plot(x, y, fig=[], name='plot', color="blue", marker_symbol='circle-open', legendgroup=[]):
global legendgroup_cnt
# If fig is empty, create a new figure
if fig == []:
fig = go.Figure()
# If legendgroup is not provided, create a new legendgroup for each curve
if legendgroup == []:
legendgroup = legendgroup_cnt
legendgroup_cnt += 1
# Create a scatter trace for markers
scatter_trace = go.Scatter(
x=x, y=y, mode='markers',
marker_symbol=marker_symbol,
marker=dict(size=14, color=color),
name=name, legendgroup=legendgroup
)
fig.add_trace(scatter_trace)
# Create a line connecting markers to the x-axis
for xi, yi in zip(x, y):
line_trace = go.Scatter(
x=[xi, xi], y=[0, yi], mode='lines',
line=dict(color=scatter_trace.marker.color),
name=name, showlegend=False, legendgroup=legendgroup
)
fig.add_trace(line_trace)
return fig
# using the function
x = np.arange(0,10,1)
y = 2*x
fig = stem_plot(x, y, fig=[], name='mystem', color="blue", marker_symbol='circle-open', legendgroup=[])
fig.show()
- Lenguaje dominante
- Python
- Estrellas
- 18.8k
- Forks
- 2.8k
- Merge medio
- 13 h 41 min
- PR fusionados (30 d)
- 21
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de plotly/plotly.py
-
P3 size: 1 task
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
P3 size: 1 task
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug P1
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
-
feature P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
feature P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Todos los issues de plotly/plotly.py
Issues similares
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
canonical/paas-charm#368 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
tech debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
addition to tracking list Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
StevenBlack/hosts#3256 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
qualcomm/qai-appbuilder#275 ·