I am plotting two lines on a graph in Matlab, and converting it to plot.ly
using the Matlab library. When I use the 'strip' = false
json property, it preserves the Matlab layout. However, it removes the nice feature where by you get all the data when you hover over one line. When 'strip' = false
, you only get data pertaining to the line you hover over.
Does anyone know how to use 'strip' = false
and yet retain all the hover overs?
Sample code in Matlab
:
X = linspace(0,2*pi,50)';
Y = [cos(X), 0.5*sin(X)];
figure
plot(X,Y)
Then generate two plot.ly
plots:
fig2plotly(gcf, 'strip', 0);
fig2plotly(gcf, 'strip', 1);
These can be respectively found at:
Note the difference in the hover over behaviour.
When you convert a matlab figure to Plotly Figure with strip=false
, the hovermode
attribute is set to closest
by default, hence it only shows data pertaining to nearest curve on hovering. To override this behaviour:
X = linspace(0,2*pi,50);
Y = [cos(X), 0.5*sin(X)];
figure
plot(X,Y)
% Convert the chart..
plotly_fig = fig2plotly(gcf, 'strip', 0)
% Set hovermode to blank (basically disable the attribute)
plotly_fig.layout.hovermode=''
% Send the updated figure to plotly:
resp = plotly(plotly_fig)
url = resp.url
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments