alandefreitas / matplotplusplus

Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
https://alandefreitas.github.io/matplotplusplus/
MIT License
4.1k stars 311 forks source link

Adding a legend seems to cause lines to not appear on line plot, Windows, MSVC #385

Open NebIAms opened 6 months ago

NebIAms commented 6 months ago

Bug category

Describe the bug When a legend is added, the lines on a plot do not always appear. I think this problem is specific to the operating system and compiler.

Steps to Reproduce From the examples, copy the one with 4 cosine functions. https://alandefreitas.github.io/matplotplusplus/appearance/labels/legend/

Then compile the code: cl /Fomain.obj /c main.cpp /TP /nologo /std:c++latest /EHsc /MD "/IC:\Program Files\Matplot++ 1.2.0\include" main.cpp link /nologo /OUT:example.exe "/LIBPATH:C:\Program Files\Matplot++ 1.2.0\lib" Gdi32.lib user32.lib Shell32.lib matplot.lib Matplot++/nodesoup.lib main.obj

This is the plot I usually get, sometimes I get a few lines, sometimes all of them: image

If I comment out the code that adds the legend I always get: image

Output (When legend is enabled)

(process:20880): Pango-WARNING **: 15:36:07.420: couldn't load font "Helvetica Not-Rotated 2200", falling back to "Sans Not-Rotated 2200", expect ugly output.

Platform

Environment Details:

Additional context Installed GNU plot, tried to install a font called Helvetica, not sure how to get the one for the library to not produce that warning. I have tried to add other text, such as a title and axes labels, those work fine.

DNKpp commented 4 months ago

I encountered the same issue. I tracked it down to the noautotitle tag. Adding notitle or an empty title directly on the plot elements didn't fix it for me. For me always the first plotted line was omitted, when the legend was shown. In fact this seems like a bug in the gnuplot, because when I do manually paste the commands into it, the same result appears.

DNKpp commented 4 months ago

I created an issue at the gnuplot repository: https://sourceforge.net/p/gnuplot/bugs/2691/