How to format the hovertext added to a text annotation in plotly? - annotations

Following this example: plotly: How to add text to existing figure?
I want to add some kind of information text box to display some information to understand the plot.
I've added the symbl ⓘ as the annotation and created the text for the "hovertext" variable in add_annotation with the following code:
custom_text = "Lorem ipsum .-........ multiple lines text"
figure.add_annotation(align='left',xanchor= 'left', hovertext = custom_text, text="<b>ⓘ</b>",font=dict(color="black", size=20 ), xref="paper", yref="paper", x=1.1, y=1.1,showarrow=False)
and I get this:
The hovering event works perfectly, however the way that the hovertext is displayed is not right. Exceding the width of the plot and the layout. Also not properly justified, etc.
Is there any way to improve the formatting of the hovertext variable to at least respect the width of the plot (or layout) and to be displayed as justified (or aligned)?
Thank you.

Related

Text component displaying lines in reverse order

Alright, I do not know how to fix this and only ran into this problem after trying to put in some longer text on a UI Text component. I have tried both pasting a value into its Text attribute through the Unity editor, and setting its value programmatically like this:
t.GetComponent<Text> ().text = "This is where meat, fish, and [...] (long text)"
Because Horizontal wrap is on, the text wraps when it reaches the edge of the available space.
However, the text displays backwards. Meaning, the start of the paragraph is at the bottom, and bottom at the top. Taking off wrap fixes this, but then the font size has to be really small (or it won't all be visible), and it can't form a normal paragraph because it has to... you know... wrap.
Is this a bug in Unity?
This is what happens - as you can see, it is displayed backwards:
The negative Line Spacing value is what is causing the issue here:
When the value of this field is less than 0, the lines will actually be arranged backwards, leading to the behaviour you're currently encountering. Just change the value to a positive number to have the text display correctly.

Can I change/fix the way Matlab creates text boxes in an eps

If I export my matlab figure as an eps using:
print('myfig','-depsc')
I then open it in another software, in my case Illustrator CS6.
The text appears ok, but what should be a single text box, say a legend entry, is actually multiple text boxes arranged so that it looks like one.
In the image below, the black text is what it looks like first, but I have also shown a copy of the same text, with each text box a different color.
If I want to edit any of this its very difficult as the space will then be messed up. Also if I change the font, the kerning gets messed up.
I have also tried using the text command to place text on the axis, and this also ends up in multiple text boxes.
Is there any way to fix this?
Am I missing something?
Just to be clear, I would like to fix matlab's eps, Not use a different software.

Adding text below text box

I have a text item on one of my plots, placed at a certain location, with a certain orientation:
th=text(x,y,'some text','HorizontalAlignment','right','rotation',rot);
Based on its position (get(th, 'Position')), or any other property, is there any way to compute the lower bound of its bounding box? I want to place another text just below it.
You could use the Extent property. You will probably need to tweak the alignments depending on what you're after, but something like this:
th = text(x,y,'some text','HorizontalAlignment','right','rotation',rot);
ex = get(th,'Extent');
text(ex(1),ex(2),'Text Below')

matlab: having a good control of MyBox, box with text

my problem is I want to have a box for additional bigger comments to the graph.
How can I create this box, so that it will be always on the right bottom side outside of my graph, and it will be automatically adjusting its size to the amount of text inside? Also, if I will have longer text, I need it to be split into more lines, not just one line extremely long.
I use it like that, however I have a poor control over what is happening, this just creates a certain size in a certain place, text is cut.. please help :)
x = rand(110)*100;
y = x;
plot(x,y)
MyBox = uicontrol('style','text')
set(MyBox,'String','optional longer information to be put into diagram')
set(MyBox,'Position',[10,0,40,10])
I am afraid you can not do that automatically - Text boxes do not use callbacks. From the documentation:
Users cannot change static text interactively. Static text controls do not activate callback routines when clicked.
What you can do is call textwrap function, which will automatically wrap the text you pass to it and return new Text box position:
MyBox = uicontrol('style','text');
% set initial position - first three values are kept constant after wrap, the hight can be changed
set(MyBox,'Position',[10,10,30,10])
% adjust the height of your Text box and wrap the text
[outstring,newpos] = textwrap(MyBox,{'optional longer information to be put into diagram'});
% set new position and text
set(MyBox,'Position',newpos, 'String', outstring)
You will have to call textwrap and set(...) yourself whenever you change the string in the text box.

if entry from database is of a certain value, substitute an image on the report

I am trying to read a value from my database, and depending on the character, have a different image show. Basically the values will either be b,r,g,or y for blue, red, green yellow and in the report I would like to show a colored circle corresponding to the entry. Does anyone know a quick way to do this? I am new to crystal reports. Thank you.
Circles are created using a rectangle (yes, really). Set the roundness=100%. Unfortunately, you can't hide/show (suppress, In Crystal's vernacular) a rectangle with conditional logic. Nor can you change its x and y values. So, for your purposes, its useless.
One option is to insert four, colored, images of circles. Suppress all but the one that you want to display.
Another option is to insert a text box, then add a circular, wingding character to it (Word can help w/ this). Use the text box's conditional formatting to change its color.
One additional suggestion to craig. You could:
create an image file for each of the coloured circles
add one of these coloured circles to the report
right click, format graphic
from the picture tab, select the formula editor for graphic location
enter a formula which looks for the relevant coloured circle image file
'C:\circles\' + {table.field} + '.jpg'
L