|
From: theozh <th...@gm...> - 2018-08-13 14:22:41
|
How can I put several labels with different label background colors or box frames? I'm using gnuplot 5.2rc4 After painful placing colored rectangle objects behind label text, I found the "set style textbox" option. However, I haven't found how to place different styles within one plot. The below example should create a red and green box but creates two green boxes. Apparently, the last style is applied to all textboxes. Can several textbox styles 1,2,3,... be defined? Like linetype, linecolor, etc.? ### different label background styles within one plot??? reset unset label unset object set label 1 "This is some text" at graph 0.1, 0.7 set style textbox opaque border lc rgb "black" lw 1 fc rgb "red" set label 2 "Some text with red background" at graph 0.1, 0.6 boxed front set style textbox opaque noborder lw 1 fc rgb "green" set label 3 "Some text with green background" at graph 0.1, 0.5 boxed front plot 10*sin(x), 10*cos(x) ### end code |
|
From: Ethan A M. <eam...@gm...> - 2018-08-13 15:47:23
|
On Monday, 13 August 2018 16:22:20 theozh wrote: > How can I put several labels with different label background colors or box frames? > I'm using gnuplot 5.2rc4 > > After painful placing colored rectangle objects behind label text, I found the "set style textbox" option. However, I haven't found how to place different styles within one plot. Development on the textbox style options kind of stalled because it is very hard to produce equivalent behaviour across all the various terminal types. That is why it is documented as an "experimental" option. textbox properties that either exist only conceptually or for only a few terminals: - control over the margin sizes - rotated box around rotated text - fill color - multiple textbox styles, to support "set label ... boxed [boxstyle N]" You are asking about that last item, but it does not exist yet. As I say, the main roadblock is that even the existing options have not been implemented on terminals gd lua pslatex x11 canvas svg It is particularly annoying that so far as I can tell there is nothing in the svg standard that would allow drawing boxed text. So we may never be able to support svg output of boxed labels, except maybe indirectly via conversion from the qt or cairo terminals to a dumped svg file. Ethan > The below example should create a red and green box but creates two green boxes. Apparently, the last style is applied to all textboxes. > Can several textbox styles 1,2,3,... be defined? Like linetype, linecolor, etc.? > > ### different label background styles within one plot??? > reset > unset label > unset object > > set label 1 "This is some text" at graph 0.1, 0.7 > > set style textbox opaque border lc rgb "black" lw 1 fc rgb "red" > set label 2 "Some text with red background" at graph 0.1, 0.6 boxed front > > set style textbox opaque noborder lw 1 fc rgb "green" > set label 3 "Some text with green background" at graph 0.1, 0.5 boxed front > > plot 10*sin(x), 10*cos(x) > ### end code |
|
From: theozh <th...@gm...> - 2018-08-13 18:43:31
|
Thank you, Ethan, for the explanations. OK, I see. Yes, "boxstyle N" would be the feature I am looking for. I am mainly working with wxt, pngcairo and pdfcairo (sometimes actually svg). How would you implement different text boxes backgrounds in these terminals? Find below find a cumbersome attempt of a workaround using colored rectangles. I was hoping that "set object rectangle at..." starts from given position with the lower left corner whereas "set object rectangle center..." has the center of the rectangle at the given position. However, gnuplot help tells me that "set object rectangle at..." and "set object rectangle center..." are identical. With this I could realize some centered boxed text, but I don't know how to "box" left or right aligned text. As a consequence, I have to set an offset for the x position depending on the text length. Furthermore, it looks like I cannot mix/add/subtract graph coordinates and char dimensions. How to find this offset automatically? How to deal with multi-line text? Any suggestions are welcome. ### workaround for different textbox backgrounds in one plot reset unset label unset object Label_1_text = "This is a red text box" Label_2_text = "This is a green text box" Label_3_text = "This is a blue text box" Label_1_color = "red" Label_2_color = "green" Label_3_color = "blue" Label_1_x = 0.1 Label_1_y = 0.8 Label_2_x = 0.1 Label_2_y = 0.7 Label_3_x = 0.1 Label_3_y = 0.6 Offset_1_x = 0.10 # How to find this value automatically depending on text length??? Offset_1_y = 0.0 Offset_2_x = 0.11 # How to find this value automatically depending on text length??? Offset_2_y = 0.0 Offset_3_x = 0.10 # How to find this value automatically depending on text length??? Offset_3_y = 0.0 set object 1 rect at graph Label_1_x+Offset_1_x,Label_1_y+Offset_1_y size char strlen(Label_1_text), char 1 fs solid 1.0 fc rgb Label_1_color front set label 1 Label_1_text at graph Label_1_x,Label_1_y left front set object 2 rect at graph Label_2_x+Offset_2_x,Label_2_y+Offset_2_y size char strlen(Label_2_text), char 1 fs solid 1.0 fc rgb Label_2_color front set label 2 Label_2_text at graph Label_2_x,Label_2_y left front set object 3 rect at graph Label_3_x+Offset_3_x,Label_3_y+Offset_3_y size char strlen(Label_3_text), char 1 fs solid 1.0 fc rgb Label_3_color front set label 3 Label_3_text at graph Label_3_x,Label_3_y left front plot sin(x) ### end code |
|
From: Ethan M. <eam...@gm...> - 2018-08-13 18:52:12
|
On Mon, Aug 13, 2018 at 11:43 AM, theozh <th...@gm...> wrote:
> Thank you, Ethan, for the explanations. OK, I see.
> Yes, "boxstyle N" would be the feature I am looking for.
> I am mainly working with wxt, pngcairo and pdfcairo (sometimes actually
> svg).
> How would you implement different text boxes backgrounds in these
> terminals?
>
I do not know of a good way to do it. That's why I started working on the
textbox
property instead. But that didn't turn out to be easy either.
t looks like I cannot mix/add/subtract graph coordinates and char
> dimensions. How to find this offset automatically? How to deal with
> multi-line text?
>
Those are the problems, yes.
Any suggestions are welcome.
>
About the only thing I can think of using the existing unsatisfactory
options is to
use multiplot, changing the background color of the textbox style in between
plot commands within the multiplot.
Ethan
|
|
From: theozh <th...@gm...> - 2018-08-13 19:45:46
|
Thanks again. Well, the multiplot "trick" is probably not the nicest but simplest workaround. It looks like that the several identical plots on top of each other create, e.g. thicker axis labels and data lines. At least that's what I believe to see in the wxt terminal. Unfortunately, interactive scaling in the wxt terminal will only work on the last (multi)plot and the other labels are gone. ### different label backgrounds in "one" plot reset set multiplot layout 1,1 unset label set style textbox opaque fc rgb "red" set label 1 "red textbox" right at graph 0.5,0.8 boxed plot sin(x) unset label set style textbox opaque fc rgb "green" set label 2 "green textbox" right at graph 0.5,0.7 boxed replot unset label set style textbox opaque fc rgb "blue" set label 3 "blue textbox" right at graph 0.5,0.6 boxed replot unset multiplot ### end code |