1

I need to reduce the font size of yticks and remove the white vertical lines plotting down from the yticks. For how much I try, it's only the xticks that get changed. Any leads would be much appreciated.

Code

fig, ax = plt.subplots(1, 1, figsize=(5, 5))
plt.subplots_adjust(left=0.1, right=0.8, top=0.8, bottom=0.1)

plt.xticks(fontsize=6)
plt.yticks(fontsize=6)
plt.rcParams['font.size'] = 6  
plt.rcParams['text.color'] = 'black'  
plt.rcParams["legend.facecolor"] = '#c2b6b6'
plt.rc('axes', titlesize=7) 


plt.legend(handles=handles, bbox_to_anchor=(1.2, 0.9), loc='upper right', borderaxespad=0., 
fontsize=6)
mosaic(data, label_rotation=0, title=name,  horizontal=False, properties=props, 
labelizer=labelizer, ax=ax)
plt.savefig("tile_plot.png")

Mosaic Plot

Mosaic Plot

Jacob Lee
  • 4,405
  • 2
  • 16
  • 37
  • Hello and welcome to SO! Unfortunately, it is not yet possible to [reproduce](https://stackoverflow.com/help/minimal-reproducible-example) the problem you are facing as it is unclear where `mosaic` comes from (statsmodels?) and `props` and `labelizer` are not defined. A small sample of data would also be welcome, you could paste a small sample of your variables like in [this question](https://stackoverflow.com/q/66161425/14148248) or create a small dataframe like in one of the many examples shown [here](https://stackoverflow.com/q/20109391/14148248). – Patrick FitzGerald Apr 23 '21 at 07:08
  • Hi Patrick, I get mosaic from "from statsmodels.graphics.mosaicplot import mosaic". Yes, it's from statsmodel. Defining props and labelizer isn't mandatory. props is used to define the color applied to each cell and labelizer writes a label on each cell. Only the 'data' variable is required actually to generate the plot. data contains a dictionary where the key resembles (x,y) cordinate name and the value represents the size of a cell. In my case, data would look like : {('FFFF', 'SameDoB') : 2.3456, ('FFFF', 'SameFname') : 1.5678}. Simply, each cell needs to be defined in this dictionary. – Asara Senaratne Apr 24 '21 at 11:46
  • I have tested your code using matplotlib 3.3.4 and statsmodels 0.12.2, [here is the result](https://i.stack.imgur.com/tuVz1.png). Activating/deactivating the different font size commands worked as expected. Now if I import seaborn and run `sns.set_theme()`, [here is the result](https://i.stack.imgur.com/72Obr.png). This looks similar to the image you have shared. Did you set a seaborn theme earlier in your script? – Patrick FitzGerald Apr 24 '21 at 19:58
  • I didn't activate any theme. But, for some reason the font size command doesn't work. Let me recheck this. Thank you for your support. – Asara Senaratne Apr 26 '21 at 09:44

0 Answers0