Skip to content

Commit

Permalink
Fixed setting of usetex and fix tex_friendly to take usetex into account
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Jun 5, 2015
1 parent f129134 commit 853b814
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 35 deletions.
3 changes: 3 additions & 0 deletions sedfitter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
from . import utils

__version__ = '0.9.3.dev'

from .plot_helpers import set_rc_params
set_rc_params()
15 changes: 1 addition & 14 deletions sedfitter/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,10 @@
from .utils import io
from .utils import parfile
from .utils.formatter import LogFormatterMathtextAuto
from .plot_helpers import tex_friendly

KPC = 3.086e21

plt.rc('text', usetex=True)
plt.rc('axes', titlesize='small')
plt.rc('axes', labelsize='small')
plt.rc('xtick', labelsize='x-small')
plt.rc('ytick', labelsize='x-small')
plt.rc('font', family='serif')
plt.rc('axes', linewidth=0.5)
plt.rc('patch', linewidth=0.5)

fp = FontProperties(size='x-small')

color = {}
Expand Down Expand Up @@ -82,11 +74,6 @@
color['faded'].append((0.50, 0.90, 0.50))


def tex_friendly(string):
return string
# return string.replace('_', '\_').replace('%', '\%')


def plot_source_info(ax, i, info, plot_name, plot_info):

labels = []
Expand Down
19 changes: 19 additions & 0 deletions sedfitter/plot_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import matplotlib.pyplot as plt


def set_rc_params():

plt.rc('axes', titlesize='small')
plt.rc('axes', labelsize='small')
plt.rc('xtick', labelsize='x-small')
plt.rc('ytick', labelsize='x-small')
plt.rc('font', family='serif')
plt.rc('axes', linewidth=0.5)
plt.rc('patch', linewidth=0.5)


def tex_friendly(string):
if plt.rcParams['text.usetex']:
return string.replace('_', '\_').replace('%', '\%')
else:
return string
13 changes: 2 additions & 11 deletions sedfitter/plot_params_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@
from .models import load_parameter_table
from .utils import io
from .utils.formatter import LogFormatterMathtextAuto


plt.rc('text', usetex=False)
plt.rc('axes', titlesize='small')
plt.rc('axes', labelsize='small')
plt.rc('xtick', labelsize='x-small')
plt.rc('ytick', labelsize='x-small')
plt.rc('font', family='serif')
plt.rc('axes', linewidth=0.5)
plt.rc('patch', linewidth=0.5)
from .plot_helpers import tex_friendly

fp = FontProperties(size='small')

Expand Down Expand Up @@ -172,7 +163,7 @@ def plot_params_1d(input_fits, parameter, output_dir=None,
ax.add_patch(pfits)

if plot_name:
source_label = ax.text(0.5, 0.95, info.source.name,
source_label = ax.text(0.5, 0.95, tex_friendly(info.source.name),
horizontalalignment='center',
verticalalignment='center',
transform=ax.transAxes,
Expand Down
12 changes: 2 additions & 10 deletions sedfitter/plot_params_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,11 @@
from .models import load_parameter_table
from .utils import io
from .utils.formatter import LogFormatterMathtextAuto
from .plot_helpers import tex_friendly

KERNEL = Tophat2DKernel(5.5, x_size=11, y_size=11, mode='oversample').array
KERNEL /= KERNEL.max() # normalize so maximum is 1

plt.rc('text', usetex=False)
plt.rc('axes', titlesize='small')
plt.rc('axes', labelsize='small')
plt.rc('xtick', labelsize='x-small')
plt.rc('ytick', labelsize='x-small')
plt.rc('font', family='serif')
plt.rc('axes', linewidth=0.5)
plt.rc('patch', linewidth=0.5)

fp = FontProperties(size='small')


Expand Down Expand Up @@ -199,7 +191,7 @@ def plot_params_2d(input_fits, parameter_x, parameter_y, output_dir=None,
pfits = ax.scatter(tsorted[parameter_x], tsorted[parameter_y], c='black', s=10)

if plot_name:
source_label = ax.text(0.5, 0.95, info.source.name,
source_label = ax.text(0.5, 0.95, tex_friendly(info.source.name),
horizontalalignment='center',
verticalalignment='center',
transform=ax.transAxes,
Expand Down

0 comments on commit 853b814

Please sign in to comment.