label - matplotlib tex renderer gives unexpected error -
i creating scatter plot color map based on values , trying make part of x_axis label italic (inspired post -> https://stackoverflow.com/a/8384685/1093485) getting latex error can not explain myself, appreciate if able explain going wrong chunk?
minimum code required reproduce problem here:
#! /usr/bin/env python import numpy np import matplotlib.pyplot plt matplotlib import rc x = [1257.422648,1298.449197,1339.475746,1419.475471,1455.52309,1460.50202,1485.533655] y = [21.84637515,18.19617016,22.29456694,5.228978612,3.888695726,12.36598466,4.201838517] z = [44.02797944,9.758071204,21.58997772,64.53887544,53.09630431,8.461254471,291.4311435] # enable latex style rc('text',usetex=true) # plot data fig=plt.figure() fig.patch.set_facecolor('white') ax=fig.add_subplot(111) s = ax.scatter(x,y,c=np.log(z)) ax.set_xlabel(r'analyte \textit{m/z}') ax.xaxis.labelpad = 7.5 cb = plt.colorbar(mappable=s,ax=ax) plt.show()
commenting rc('text',usetex=true)
causes plot show without italics. whole traceback rather large seems revolve around part (if read correctly):
runtimeerror: latex not able process following string: '$1450$'
anyone have suggestion on isolate problem?
Comments
Post a Comment