Python Forum
<Figure size 640x480 with 0 Axes> problem during plotting in matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
<Figure size 640x480 with 0 Axes> problem during plotting in matplotlib
#1
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:

Attached Files

Thumbnail(s)
       
Reply
#2
Your code never calls the plot_php_plots() function. You also never call plt.show() to draw all the plots.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dynamically plotting graphs with matplotlib CAD79 11 1,092 Apr-17-2024, 04:09 PM
Last Post: deanhystad
  [solved] Save a matplotlib figure into hdf5 file paul18fr 1 2,655 Jun-08-2021, 05:58 PM
Last Post: paul18fr
  Plotting issue Matplotlib garam0 0 1,631 May-23-2020, 12:11 AM
Last Post: garam0
  It doesn't show scatter plot but it says: "<Figure size 640x480 with 1 Axes>" dcardonaa 0 3,592 Oct-10-2019, 02:34 AM
Last Post: dcardonaa
  Dynamically placing axes in subplots via dataframe plot naftis 1 3,075 Jul-29-2019, 12:10 AM
Last Post: scidam
  Problem with Matplotlib.pyplot LTMP 1 2,940 Aug-21-2018, 04:50 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020