![]() |
<Figure size 640x480 with 0 Axes> problem during plotting in matplotlib - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: <Figure size 640x480 with 0 Axes> problem during plotting in matplotlib (/thread-42253.html) |
<Figure size 640x480 with 0 Axes> problem during plotting in matplotlib - Kashfi - Jun-04-2024 I am trying to plot a PDP plot using Matplotlib, but I find an error that indicates that figures were created but nothing was drawn on it. This is my code: [inline] from perovmldis.ML_utilities.ML_plotting import plot_pdp_plots plot_pdp_plots(best_estimator,dataset,regression_feature_list,ranked_features[0:3],ranked_labels[0:3]) [/inline] import matplotlib.pyplot as plt from matplotlib.pyplot import annotate, savefig, rcParams, rc, tick_params, xlabel, ylabel, xlim, ylim, legend, title from sklearn.metrics import roc_curve, auc from sklearn.preprocessing import label_binarize from .performance_functions import BinaryClassification from sklearn.tree import export_graphviz from subprocess import call import os, shutil import seaborn as sns from itertools import combinations import numpy as np from pdpbox import pdp def plot_pdp_plots(model,df,feature_list,ranked_features,ranked_labels): feature_pairs = np.array(list(combinations(ranked_features,2))) feature_labels = np.array(list(combinations(ranked_labels,2))) for i in range(len(feature_pairs)): inter1 = pdp.PDPInteract(model=model,df=df, model_features=feature_list,features=feature_pairs[i],feature_names=feature_labels[i], pred_func=None, n_classes=0, memory_limit=0.5, chunk_size=-1, n_jobs=1, predict_kwds=None, data_transformer=None, num_grid_points=[10, 10], grid_types='percentile', percentile_ranges=[(5, 95), (5, 95)], grid_ranges=None, cust_grid_points=None) fig, axes = inter1.plot(plot_type='contour', plot_pdp=False, to_bins=True, show_percentile=False, which_classes=None, figsize=None, dpi=300, ncols=2, plot_params=None) fname = feature_pairs[i][0]+'_'+feature_pairs[i][1] +'.pdf' plt.tight_layout() plt.savefig(fname, dpi=500,format='pdf')I am expecting similar like the picture: RE: <Figure size 640x480 with 0 Axes> problem during plotting in matplotlib - deanhystad - Jun-04-2024 Your code never calls the plot_php_plots() function. You also never call plt.show() to draw all the plots. |