04-01-2019 04:33 AM
Hello,
does anyone know if it is possible to programmatically adapt the background color of the legend of a xy plot?
I can alter the color of the main plot via a property node but I couldn’t find an appropriate property node for this need.
I would be thankful for any piece of advice.
Best regards,
Franz
04-02-2019 02:28 AM
Dear Franz,
the background of the legend cannot be set separately, it changes together with the bacground colour of the plot area. So you can use the property node of the graph to change the background colours:
Plot Area>>Colors>>BG Color.
I have made you some screenshots for clarification.
Best Regards,
Akos
National Instruments
04-02-2019 03:24 AM
If that is something you really want, you can always make it transparent, and put something behind it that does change colors. Like a picture ring, a decoration or a picture control. Or a Boolean indicator with two colors.
This could turn into a nightmare, for instance auto sizing of the legend will not automatically adopt to the other object...
04-02-2019 08:28 AM
Hello Akin,
thank you very much for your answer, however this is not the exact method I wanted to conduct.
I actually wanted to recolor the grey area in the Legend. It is possible via the Property Node “Frame Colour” for the main diagram, but this Node is not applied for the legend background.
Background of my question is, that I would like to create a Screenshot of the Diagram by the method “Export Image” and before exporting it, I would like to recolor the grey area in a white background and reverse this afterwards.
By only applying the method “Export Image” the grey areas will also be exported.
Best regards,
Franz
04-02-2019 08:37 AM
Unless that property node exists and is hiding so well we haven't found it, it doesn't seem like you can.
What you could do as a workaround is create a second graph that you've assigned the alternate colors to. When you programmatically want to capture the image, you capture it from the alternate plot. You might need to change the visibility of the regular plot and alternate plot so show it, then switch back when done.
04-02-2019 09:06 AM
Hello Franz,
if you use the browse option of the property node, you can find the PlotArea:Colors property (Plot Area>>Colors>>All Elements), but this doesn't change the colour of the part you would like to either.
Best Regards,
Ákos
04-02-2019 09:31 AM
@F.S94 wrote:
thank you very much for your answer, however this is not the exact method I wanted to conduct.
What is wrong with this? It is probably the only workable method.
Note that you can get a reference to the legend (and even it's elements). But you need a user to click in the legend at least once...
04-02-2019 10:32 AM
Let's be clear here as to what colors the OP is talking about. The title talks about the color of the legend. The latest picture looks like he wants the frame color of the legend box itself. He is not looking at plot areas.
04-03-2019 02:54 AM - edited 04-03-2019 02:56 AM
Setting the Graphs frame color is a problem for me. It won't actually update the frame color until I stop the VI. In LV13, so maybe that got fixed. EDIT: the same solution will do the trick.
04-03-2019 06:59 AM
Interesting. So the VI you posted is telling me that the frame of the plot legend is actually a decoration exists on the front panel and is not a part of the graph control itself?
That begs the question, how do you change the color on a specific one? I duplicated the chart and ran the VI. With you VI, there was exactly one decoration in the array. So I figured putting the 2nd chart would give me two. Nope, still only one decoration in the array, and its color does not change.