matplotlib / matplotlib/mplfinance
What is the most elegant way to implement ribbons?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 4.4k
- Forks
- 678
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I am currently thinking about the most elegant way to display 1-2 scatter lines below the chart.
Are there any ideas from others who have already implemented this?
These are my first ideas:

```
import mplfinance as mpf
output = sp_500 ['2021-01-01':].copy()
output["sma_above"] = np.where (output.Close > output.sma, output.sma, np.nan)
output["sma_below"] = np.where (output.Close < output.sma, output.sma, np.nan)
output["ribbon_above"] = np.where (output.Close > output.sma, 1, np.nan)
output["ribbon_below"] = np.where (output.Close < output.sma, 1, np.nan)
add_plt = [
mpf.make_addplot(output["sma_above"],color="green"),
mpf.make_addplot(output["sma_below"],color="red"),
mpf.make_addplot(output["ribbon_above"], panel=1, color="g", type='scatter'),
mpf.make_addplot(output["ribbon_below"], panel=1, color="r", type='scatter'),
]
mpf.plot(
output,
addplot=add_plt,
figsize=(16, 9),
style="charles",
type="candle",
title='S&P 500 - weekly',
datetime_format='%d.%m.%y',xrotation=45,
)
```
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die Beispielaufrufe des Issues für mpf.make_addplot und mpf.plot zu überprüfen, einschließlich der separaten Einstellungen für Panel und Scatter. Im Issue werden weder Dateien noch Tests genannt. Daher besteht der erste Schritt darin, diese Einstiegspunkte zu finden und die vorgesehene Ribbon-API zu bestimmen. Als abgeschlossen gilt die Aufgabe, wenn ein abgestimmtes Design und eine funktionierende Möglichkeit vorhanden sind, Ribbons unterhalb des Charts anzuzeigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- matplotlib, python
- Bereich
- data-visualization
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100