How can I change axis spacing in partial dependence plots

Illustration
Matthew Linn - 2022-04-13T12:12:26+00:00
Question: How can I change axis spacing in partial dependence plots

I am fitting a random (regression) forest and creating partial dependence plots. In order to make the plots easier to visualize, I remove observations whose predictor (X-variable) takes values in the extreme tails (lower than first percentile and larger than 99th percentile). When I create the partial dependence plots, the x-axis has equally spaced ticks. That is, even if 95% of the x-values are between zero and 5 while only 5% are between 6 and 10, I still have an x-axis with ticks at 1,2,3,4,5,6,7,8,9,10. I want something where the ticks occur at the 10th,20th,30th,40th,50th,60th,70th,80th,90th, 100th percentiles. Is this possible? below is the code I'm using for the plots:     % train model Forest_fit = TreeBagger(NumTrees,X,Y,'Method','regression','OOBPredictorImportance','on','CategoricalPredictors',cat_X_vec) ; x_ax = prctile(X(:,1),1:99); % exclued top and bottom 1 percent for scale purpose ax = plotPartialDependence(Forest_fit,1,X,'QueryPoints',x_ax');

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

This is not tested but to get the percentiles you listed, 

 

x_ax = prctile(X(:,1),10:10:100)

and use those percentiles as x-ticks,

set(ax, 'XTick', x_ax)

If this solution isn't want you're asking for, please attach some data.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!