Biblioteca que puede superponer un texto con un mapa de calor

Estoy buscando una biblioteca que pueda superponer un texto con un mapa de calor. Es decir, agregue un resaltado con degradado. Simplemente definiría un valor para cada carácter: el valor definiría la intensidad del resaltado/mapa de calor.

Ejemplo :

ingrese la descripción de la imagen aquí

Idealmente, debería poder llamarlo fácilmente desde Python.

Suena bien. También me gustaría verlo manejar palabras, no solo caracteres. Y, además de definido por el usuario, tiene una opción para la frecuencia de palabras del mapa de calor automático.

Respuestas (1)

Podría definir un nuevo comando LaTeX:

Ejemplo de https://arxiv.org/abs/1603.01547 :

ingrese la descripción de la imagen aquí

\newcommand{\attvis}[2]{\definecolor{att}{rgb}{1, #2, #2} \colorbox{att}{#1}}

[...]

\begin{figure}[t]
\small
\centering%
\begin{tabular}{| p{\dimexpr0.47\textwidth-2\tabcolsep-\arrayrulewidth\relax}|   }
\hline
\hspace{0.25\textwidth}\textbf{...}
\\
%according to a entity21 lawmaker (education policy is super gay, obviously); %\attvis{entity25}{0.86},
%who an op-ed writer for entity28, entity29, claims is being used by entity30 to 
%"attract young girls" to her show (uh-huh); the entity36 princess movie "entity40"
%according to radio hosts in entity38 (that dress!); and now, according to a 
%potential 2016 entity34 presidential contender, \attvis{entity32}{0.81}, there's prison. yep, %prison. 
%stay away from crime, kids. turns ya gay. \attvis{entity32}{0.705}, who ,let me reiterate , 
%is a potential presidential candidate from a major entity54 party 
what was supposed to be a fantasy sports car ride at \attvis{@entity3}{0.97} turned deadly when a \attvis{@entity4}{0.47} crashed into a guardrail . the crash took place sunday at the @entity8 , which bills itself as a chance to drive your dream car on a racetrack . the \attvis{@entity4}{.99} 's passenger , 36 - year - old @entity14 of @entity15 , @entity16 , died at the scene , @entity13 said . the driver of the \attvis{@entity4}{0.98} , 24 - year - old @entity18 of @entity19 , @entity16 , lost control of the vehicle , the \attvis{@entity13}{0.82} said .
\\
\hspace{0.25\textwidth}\textbf{...}
\\
\includegraphics[width=0.44\textwidth]{att_map}
\\
\hline
\hline
%\begin{figure}[h!]

% \caption{See that the ....}
% \label{fig:attention_1}
%\end{figure}

officials say the driver , 24 - year - old @entity18 , lost control of a \_\_\_\_\_
\\
\hline

\end{tabular}
\caption{Attention in an example with anonymized entities where our system selected the correct answer. Note that the attention is focused only on named entities.}
\label{tab:goodEx}
\end{figure}
¿Se puede llamar fácilmente desde Python, como lo solicitó (de usted mismo, aparentemente ;-)? ¿Necesitaría algún conocimiento de Latex para usarlo?
@Mawg, por lo que sé, no se puede llamar fácilmente desde Python :( solo necesita un conocimiento muy limitado de Latex.