自定义不透明度 Plotly 烛台
Custom opacity Plotly candlesticks
我想知道我们是否可以更改烛台的不透明度,使它们与边缘颜色相同?
like that
not like that
- 曾经 https://plotly.com/python/candlestick-charts/#simple-candlestick-with-pandas 拥有 MWE
- 明确设置 fillcolor 和 line_color 的简单案例 increasing and 减少
import plotly.graph_objects as go
import pandas as pd
from datetime import datetime
df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv"
)
df = df.head(8)
fig = go.Figure(
data=[
go.Candlestick(
x=df["Date"],
open=df["AAPL.Open"],
high=df["AAPL.High"],
low=df["AAPL.Low"],
close=df["AAPL.Close"],
)
]
)
fig.update_xaxes(rangebreaks=[{"pattern": "day of week", "bounds": [6, 1]}])
fig.update_traces(
{
d: {"fillcolor": c, "line": {"color": c}}
for d, c in zip(["increasing", "decreasing"], ["red", "green"])
}
)
我想知道我们是否可以更改烛台的不透明度,使它们与边缘颜色相同?
like that
not like that
- 曾经 https://plotly.com/python/candlestick-charts/#simple-candlestick-with-pandas 拥有 MWE
- 明确设置 fillcolor 和 line_color 的简单案例 increasing and 减少
import plotly.graph_objects as go
import pandas as pd
from datetime import datetime
df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv"
)
df = df.head(8)
fig = go.Figure(
data=[
go.Candlestick(
x=df["Date"],
open=df["AAPL.Open"],
high=df["AAPL.High"],
low=df["AAPL.Low"],
close=df["AAPL.Close"],
)
]
)
fig.update_xaxes(rangebreaks=[{"pattern": "day of week", "bounds": [6, 1]}])
fig.update_traces(
{
d: {"fillcolor": c, "line": {"color": c}}
for d, c in zip(["increasing", "decreasing"], ["red", "green"])
}
)