, pgf/tikz.
-, matplotlib (.. ) pgf, png ( op).
matplotlib2tikz. quadmesh png, . , , , Axes , png.
, , .
:
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
df = pd.DataFrame.from_csv("test.csv", sep=',')
sns.set('paper', 'white',
rc={'font.size': 10, 'axes.labelsize': 10,
'legend.fontsize': 8, 'axes.titlesize': 10,
'xtick.labelsize': 8,'ytick.labelsize': 8,
"pgf.rcfonts": False,
})
plt.rc('font', **{'family': 'serif', 'serif': ['Times']})
plt.rc('text', usetex=True)
fig, ax = plt.subplots(figsize=(6,6))
ax = sns.heatmap(df, linewidths=.5, ax=ax, cbar=False)
fig.savefig('heatmap_nocbar.pgf')
, cbar=False
:
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from matplotlib2tikz import save as tikz_save
df = pd.DataFrame.from_csv("test.csv", sep=',')
sns.set('paper', 'white',
rc={'font.size': 10, 'axes.labelsize': 10,
'legend.fontsize': 8, 'axes.titlesize': 10,
'xtick.labelsize': 8,'ytick.labelsize': 8,
"pgf.rcfonts": False,
})
plt.rc('font', **{'family': 'serif', 'serif': ['Times']})
plt.rc('text', usetex=True)
fig, ax = plt.subplots()
ax = sns.heatmap(df, linewidths=.5, ax=ax, )
tikz_save('colormap.tex', figure=fig, strict=True)
. , , .
colormap.tex , , .
colormap.tex:
\begin{tikzpicture}
\begin{axis}[
... % definition of axis: delete these lines
colorbar,
colormap={mymap}{[1pt]
...
, :
\begin{tikzpicture}
\begin{axis}[
hide axis,
colorbar,
colormap={mymap}{[1pt]
...
\end{axis}:
]
... %delete these lines
\end{axis}
, github
tex
\input{heatmap_nocbar.pgf}
\input{colorbar.tex}
, github.
, , , , matplotlib matplotlib2tikz, .