Feature Request: Rotate prtScoreConfusionMatrix XAxisLabels
luster opened this issue · 1 comments
When the class names are too long, running prtScoreConfusionMatrix causes the x-axis class labels to overlap. Tried using this, but it's kind of a hack. The text also appears distorted unless rotating either 90 or 270 degrees. Tried looking into prtUtilPlotConfusionMatrix and prtScoreConfusionMatrix, but it seems the labels are set as XTickLabels, so a handle is never set for them. If the x-axis class labels were set as text objects, they would have handles so that you could rotate them properly.
Hi Luster!
First off - thanks very much for your comment and feedback - we hope you're finding the PRT useful!
Rotating tick labels is a major nightmare in MATLAB (I worked on one of the original tech-support provided rotate tick-label functions when I was at TMW, and it was a pain.)
As you've noticed, if MATLAB used text objects and gave us handles to them, this would be easier. I'm hesitant to change the default behavior of the confusion matrix plotting to do anything even a little out of the ordinary - we're basically waiting for TMW to finally make the jump into true OO handle graphics before we really fight any additional low-level graphics things (there's a bunch of undocumented evidence that this change is coming soon; google around to find it).
However, the power of transferring from the xticklabel to handles pointing to the text seems easy to implement, and useful. So we added a new function: prtUtilConvertXtickLabelsToObjets. This takes the xticklabels from the current axis, turns them into text objects, and provides handles to them. For example:
ds = prtDataGenMarysSimpleSixClass;
c = prtClassKnn + prtDecisionMap;
yOut = c.kfolds(ds,10);
prtScoreConfusionMatrix(yOut)
h = prtUtilConvertXtickLabelsToObjets;
set(h,'rotation',20); %You'll need to adjust the positions of all the
% xTickLabels, xlabels, etc.
Note that we aren't working on making sure the new text doesn't overlap anything else, or cover up the xlabel - that's up to the user. But for now, the utility function prtUtilConvertXtickLabelsToObjets should get you 90% of the way to where you want to be.
Let us know if this helps, and of course, let us know if you have any other issues, questions, or suggestions.