4

I am using GetDist for plotting contours in jupyter. I am wondering how to change the size of numbers in axes and labels of parameters. There are some lines in the code containing labels as follows:

a,b,c = np.genfromtxt('data/data.txt',unpack=True)
names = ['H','M','z']
labels =  ['H','M','z']
samples0 = MCSamples(samples=[a,b,c],names = names, labels = labels)
g.triangle_plot([samples0],['H','M','z'],legend_labels=['Summation of data'], legend_loc='upper right',filled=True)

The problem is when the number of parameter goes up, the plot should be smaller to placed in a printed paper and then we cannot see numbers and parameters' labels.

Thank you

Ma Y
  • 696
  • 8
  • 19

3 Answers3

3

I found the answer which is tricky

g.settings.axes_fontsize = 20
g.settings.lab_fontsize = 30
g.settings.x_label_rotation=47
g.settings.legend_fontsize = 40

by the use of g.setting in GetDist we can customize the plots.

Ma Y
  • 696
  • 8
  • 19
2

you can use the plot.legend(loc=2, prop={'size': 6}) to increase the legend size This takes a dictionary of keywords corresponding to matplotlib.font_manager.FontProperties properties. more about legends

1). if you want to increase the size of the plotting data according to x values this would be helpful.

# yvalues is the y value list widthscale = len(yvalues)/4 figsize = (8*widthscale,6) # fig size in inches (width,height) figure = pylab.figure(figsize = figsize) # set the figsize

if you want increase them without dynamically you can use plot.rc function eg.

import matplotlib.pyplot as plt

SMALL_SIZE = 8
MEDIUM_SIZE = 10
BIGGER_SIZE = 12

plt.rc('font', size=SMALL_SIZE)          # controls default text sizes
plt.rc('axes', titlesize=SMALL_SIZE)     # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE)    # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE)    # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE)    # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE)    # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title

2).second option would be


plt.rcParams["axes.labelsize"] = 22


or directly control the size of the label


ax.set_xlabel("some label", fontsize=22)

To control the legend's fontsize you can use rcParams


plt.rcParams["legend.fontsize"] = 22


or directly specify the size in the legend


ax.legend(fontsize=22)
AmilaMGunawardana
  • 1,604
  • 2
  • 13
  • 32
0

You can change the font size of the labels to adjust them so they are more visible. If you can edit your question to include an MCVE by adding some dummy data and your plotting code, it will be much easier to provide more specific help.

Nathaniel
  • 3,230
  • 11
  • 18