|
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 |