Closed JasonGross closed 4 months ago
Note that svg output on plotly just rasterizes the heatmap, so it seems reasonable to do something similar here.
I never used it, so I don't know what it should take. As you mentioned maybe not so much. I will try to look at it this week :) You can also make a pull request if you manage to do it :wink:
Here is an example usage:
This generates
% This file was created with tikzplotlib v0.10.1.
\begin{tikzpicture}
\definecolor{darkgray176}{RGB}{176,176,176}
\begin{axis}[
colorbar,
colorbar style={ylabel={}},
colormap/viridis,
point meta max=0.992047081681384,
point meta min=0.00898827770104482,
tick align=outside,
tick pos=left,
title={Heatmap Example with Matplotlib},
x grid style={darkgray176},
xmin=-0.5, xmax=9.5,
xtick style={color=black},
y dir=reverse,
y grid style={darkgray176},
ymin=-0.5, ymax=9.5,
ytick style={color=black}
]
\addplot graphics [includegraphics cmd=\pgfimage,xmin=-0.5, xmax=9.5, ymin=9.5, ymax=-0.5] {heatmap-000.png};
\end{axis}
\end{tikzpicture}
So indeed it seems that the thing to do is just to create a raster image.
The corresponding code for an example usage in plotly:
import plotly.express as px
import numpy as np
data = np.random.rand(10,10)
fig = px.imshow(data, color_continuous_scale='Viridis', title='Heatmap Example with Plotly Express')
fig.show()
NB: in the creation of the PNG file from the heatmap, for some reason it happens that all blocks may not have the same size. During the process of reduction of the file, this lead to a wrong reduced size.
So what is currently done is that when the block do not have the same size, no reduction of the png is done at all. It takes more disk memory (1.5 ko instead of 131 o).
@JasonGross I don't think this is perfect, but I managed to add heatmaps to the exports type of the library.
I see "Trace type heatmap is not supported yet". Would it be possible to support this? What would it take?