0

I have an existing system using matplotlib that just saves the figure to a .png file:

rootfilename = '%d.png' % t
fyle = settings.MEDIA_ROOT + '/' + rootfilename
fig.savefig(fyle)
context = {'ourimg' : rootfilename}
return render(request, 'sensors/img.html', context)

That works to show the graph I am expecting: The image with matplotlib: looks fine

But I tried using mpld3:

g = mpld3.fig_to_html(fig)
return HttpResponse(g)

... and it's not even close. I get the y ticks correct (but smaller) but none of the graphs I see on the same figure saved to a file and displayed the other way.

I must be missing something; help please!

Mark McWiggins
  • 621
  • 6
  • 20
  • What is the meaning of the sentence "None of the graphs I see on the same figure saved to a file and displayed the other way"? Without [mcve] it's anyways hard to know what's wrong. But in general consider that `mpld3`'s support for matplotlib is not complete. – ImportanceOfBeingErnest Sep 04 '19 at 11:30
  • The display just shows the outline: y ticks and legend and xticks (dates messed up but I've seen a post on how to fix that) ... and no data graphs displayed at all. – Mark McWiggins Sep 04 '19 at 15:56
  • If mpld3 doesn't yet fully support matplotlib; what's the shortest path to get this done? A REST service for a duplicate of the data to be grabbed by Javascript? Or something else that works with matplotlib? – Mark McWiggins Sep 10 '19 at 22:26

0 Answers0