parrt / dtreeviz

A python library for decision tree visualization and model interpretation.
MIT License
2.89k stars 332 forks source link

font name/size not respected #229

Closed parrt closed 1 year ago

parrt commented 1 year ago

in trees.py, the label font size arguments are ignoring but we should also be specifying the font.

def regr_leaf_node(node, label_fontsize: int = 12): ...
def class_leaf_node(node, label_fontsize: int = 12): ...

It eventually calls the node_label() func:

<font face="Helvetica" ...>
parrt commented 1 year ago

Well we are at it, we should look at this one. ticks_fontsize is ignored:

def _draw_barh_chart(counts, size, colors, filename, label=None, fontname="Arial", ticks_fontsize=9, graph_colors=None):

@mepland I think this one is a function you added so it might be fresh in your mind.

mepland commented 1 year ago

Well we are at it, we should look at this one. ticks_fontsize is ignored:

def _draw_barh_chart(counts, size, colors, filename, label=None, fontname="Arial", ticks_fontsize=9, graph_colors=None):

@mepland I think this one is a function you added so it might be fresh in your mind.

_draw_barh_chart() doesn't actually draw any ticks currently, so we could probably just remove the ticks_fontsize=9 parameter in this case.

Relatedly, I would like to replace most of this block:

    ax.spines['left'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.spines['bottom'].set_visible(False)
    ax.tick_params(axis='x', which='both', top=False, bottom=False, left=False, right=False)
    ax.get_yaxis().set_visible(False)

with that axis formatting util function I mentioned as point 2 here.

mepland commented 1 year ago

It eventually calls the node_label() func:

<font face="Helvetica" ...>

@parrt let's try to merge https://github.com/parrt/dtreeviz/pull/224 before messing with this code too much, to try and avoid merge issues.

parrt commented 1 year ago

_draw_barh_chart() doesn't actually draw any ticks currently

I fixed that just now with https://github.com/parrt/dtreeviz/commit/5cf1b61f2519617435a7a971601c8987789440aa

mepland commented 1 year ago

@parrt has this issue been fully addressed in dev now?

parrt commented 1 year ago

Looking at the code it seems all right but I can't remember exactly what example I was running. Let's close