Jim Blum
Jim Blum

Reputation: 2646

Python "Invalid rgb arg "None""

I have a code that creates and saves a plot, using matplotlib and python. The code runs flawlessly at the laptop of my supervisor, who has matplotlib 1.1.1. However, despite the fact that I have a newer version of matplotlib(1.3.1) I get the following error when executing this command:

plt.savefig("outputs/" + run_uuid +".pdf", facecolor='white', bbox_inches='tight', pad_inches=0.0)

I get the following Traceback on that command:

Traceback (most recent call last):
  File "vis.py", line 1116, in <module>
    plt.savefig("outputs/" + run_uuid +".pdf", facecolor='white', bbox_inches='tight', pad_inches=0.0)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 561, in savefig
    return fig.savefig(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 1421, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 2167, in print_figure
    **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 1952, in print_pdf
    return pdf.print_pdf(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_pdf.py", line 2352, in print_pdf
    self.figure.draw(renderer)
  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 1034, in draw
    func(*args)
  File "/usr/lib/pymodules/python2.7/mpl_toolkits/axisartist/axislines.py", line 774, in draw
    super(Axes, self).draw(renderer, inframe)
  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 2086, in draw
    a.draw(renderer)
  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/lines.py", line 530, in draw
    gc.set_foreground(ln_color_rgba)
  File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 921, in set_foreground
    self._rgb = colors.colorConverter.to_rgba(fg)
  File "/usr/lib/pymodules/python2.7/matplotlib/colors.py", line 365, in to_rgba
    'to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc))
ValueError: to_rgba: Invalid rgba arg "None"
to_rgb: Invalid rgb arg "None"
cannot convert argument to rgb sequence

I couldn't find anything useful in the net for this error. Do you know what am I doing wrong?

I also tried to rewrite this

plt.savefig("outputs/" + run_uuid +".pdf", facecolor='white', bbox_inches='tight', pad_inches=0.0)

to this:

plt.savefig("outputs/" + run_uuid +".pdf")

but without any progress

Upvotes: 0

Views: 1380

Answers (1)

linpingta
linpingta

Reputation: 2620

I think reason is facecolor doesn't have value of 'white'.

From the following link, no 'white' exists in facecolor setting.

what if simply use plt.savefig("your path")? I think default background color should be white.

Upvotes: 1

Related Questions