[FIXED] Mpl_util.plot_image cannot provide custom filename

Hello everyone,
thanks everyone for this super interesting framework where even coding noobs like me can get things done :slight_smile:

A while back I came accross an issue with the anvil-uplink mpl_util package that still persists so I thought I would report it.
I am creating some plots using matplotlib in the backend and pass them to the frontend using the anvil.mpl_util.plot_image(filename = 'my_interesting_plot.png') method. I would like to provide a custom filename so that the plots could be downloaded easily without having to rename each of them individually.

According to the documentation Anvil Docs | anvil.mpl_util I should be able to provide a custom filename parameter, however whenever I provide a filename, the app throws an exception
TypeError: print_figure() got multiple values for argument 'filename'

The anvil.mpl_util somehow provides a filename already. I tried inspecting the object returned by the save_fig() method. There is a get_name method, which when run yields a plot.png string, but this one cannot be set or changed.

Would it be possible to provide a custom filename to the plot_image() method somehow so that I can download the file without having to overwrite each filename manually?

To confirm this test I updated anvil-uplink from 4.0 to the latest 4.1 version.
Thanks a lot for having a look,
Petr

edit: I updated the anvil.mpl_util.plot_image method with the filename parameter example

Hi @petr.z, this is in fact a bug, thanks for bringing it to our attention! I will move this thread to bug reports and we’ll take a look to get it fixed.

Thanks for the heads-up - you’ll see a fix for this roll out in the next few days.

1 Like

Hello Meredydd, just a small question: You mentioned this bug would be addressed in an update to the anvil-uplink package. I understand you probably wait for a few bugs to be addressed and thoroughly tested so that you do not update too often, but I just thought I would remind myself in case it just got forgotten :slight_smile: Thanks a lot, Petr