Hi there,
I know it is possible to make nice streamline plots, but I was wondering how to add a color gradient the same way matplotlib does (see attached pic)?
thanks
Hi there,
I know it is possible to make nice streamline plots, but I was wondering how to add a color gradient the same way matplotlib does (see attached pic)?
thanks
Hi @Alexboiboi,
This isnโt possible at the moment, but it would be a great addition. Feel free to open a feature request at https://github.com/plotly/plotly.py/issues to discuss.
-Jon
Hi @jmmease,
I just found a work around to make this โpartiallyโ work. The only thing itโs missing is the ability to apply a color scale to a line chart (which is still an open issue, see https://github.com/plotly/plotly.js/issues/581).
import plotly.graph_objs as go
import plotly.figure_factory as ff
from scipy.interpolate import RegularGridInterpolator
import numpy as np
x = np.linspace(-3, 3, 100)
y = np.linspace(-3, 3, 100)
Y, X = np.meshgrid(x, y)
u = -1 - X**2 + Y
v = 1 + X - Y**2
# Create streamline figure
ff_fig = ff.create_streamline(x, y, u, v, arrow_scale=.1)
fig = go.FigureWidget(ff_fig)
t = fig.data[0]
def f(x,y):
return np.sin(x)*np.cos(y)
data = f(*np.meshgrid(x, y, indexing='ij'))
my_interpolating_function = RegularGridInterpolator((x, y), data)
pts= np.array([t.x,t.y]).T
colors = my_interpolating_function(np.nan_to_num(pts))
t.mode='markers'
t.marker.color = colors
t.marker.colorscale='Viridis'
fig