I have an application that create lines on the cursor position. When I enter the datacursormode to create datatips, it create on the lines that follow the cursor position.
I was wondering how to remove them from being visible to the datacursormode, but don't making them invisible.
To solve it, make its handle HitTest off.
I.e, the line is created by a plot or line command, then add the following pair value at its end:
plot(…,'HitTest','off');
line(…,'HitTest','off');
This will make the line invisible for the datacursormode.
Related
Let's say I want to place hyphen at the end of each line. I know I can do that by pressing Shift+Alt button in windows(to enable multiline cursors) and then jump to the end of line. (shown in the image below)
However, I want to place the cursor(and therefore hyphen) at the same position. In other words, I want hyphen to be below each another. Here is the pic of what I want -
Is there anyway to do this in vscode using multi-line shortcuts ?
Why do I want this ? To increase readability of my code.
Is there a way to make Emacs preserve my cursor's horizontal position, when going up and down between lines of varying widths in a file?
I'll explain what I mean by example. Say I have 3 lines of text:
1: ------a
2: --b
3: --c---d
Say the cursor is at the position marked above by a. If I move down a line, the cursor will be at b. If I move down again, it will be at c. But I actually want to end up at d.
Is there a way to make Emacs do that automatically, so that I can go from a to b to d just by pressing the down arrow twice? Emacs would have to remember my horizontal position from my most recent horizontal movement, and try to restore that horizontal position each time I move vertically.
Customize user option goal-column to nil.
(You can also use command set-goal-column anytime to set goal-column to the current column.)
E.g something like below (I'd like a <-- arrow pointing in one direction, and a --> arrow pointing in another).
I'd also like it to be close to publication-quality, so simply using --> probably wouldn't work.
In the last versions of Matlab you can use the function annotation() to create some annotation objects in the figure (such as arrows).
The following example, extracted from the documentation, adds a text arrow to the graph by defining the text arrow to start from (0.3,0.6) and extend to (0.5,0.5) in normalized figure coordinates:
figure
plot(1:10);
annotation('textarrow', [0.3,0.5], [0.6,0.5],'String' , 'Straight Line');
More info: Matlab documentation
Check out the following code on the MATLAB File Exchange: arrow.m. I just tried it out, and it is pretty neat. You can draw arrows using the mouse by simply calling the function
arrow
and then dragging the mouse icon across the plot to draw the arrow from its start to end position.
Or supply start and stop coordinates for the arrow as
arrow([100 50],[300 200],'FaceColor','r','EdgeColor','r')
which will draw the arrow in red.
I know that one can insert a colorbar by clicking the colorbar icon in the clustergram GUI. Is there a way to do it programmatically?
I tried
cgo = clustergram(data)
colorbar;
This makes a colorbar in a new figure window. How can a colorbar be created with proper positioning in a clustergram figure as if the button was clicked?
There is a function buried away (HeatMap.plot>showColorbar) that neatly positions the colorbar to the left of both the heat map and the dendogram (the lines). Just running colorbar(...) will mess up the relative positioning of the dendogram and the heatmap. So you need to somehow run the callback or carefully duplicate all of the position computations. It's easier to just run the callback. Here's how.
To create the colorbar programmatically for a clustergram, and keep the color bar button in sync, you need to use the button's assigned callback and set the button's state.
Create the clustergram:
load filteredyeastdata
cgo = clustergram(yeastvalues(1:30,:),'Standardize','Row');
Get the handle for color bar button:
cbButton = findall(gcf,'tag','HMInsertColorbar');
Get callback (ClickedCallback) for the button:
ccb = get(cbButton,'ClickedCallback')
ccb =
#insertColorbarCB
[1x1 clustergram]
That gives us a handle to the function assigned by the callback (#insertColorbarCB), and the function's third input argument (the clustergram object). The button's handle and an empty event object are implicitly the first two arguments.
Change the button state to 'on' (clicked down):
set(cbButton,'State','on')
Run the callback to create the colorbar:
ccb{1}(cbButton,[],ccb{2})
Note that the button State must be changed to 'on' first, otherwise the callback won't do anything.
I just managed to solve this problem.
What I did:
I added this function to the clustergram code (I put it at line 1486)
%%%%%%%%%%%%%%
function insertColorbarCBALWAYS(obj)
hFig= gcbf;
obj.Colorbar = true;
end
%%%%%%%%%%%%%%%
and then at line 415 of the clustergram.m file I added this line of code
insertColorbarCBALWAYS(obj);
to call the above function. Save and go: now the colorbar will always be there, once the clustergram is drawn.
Previous method was not working for me so I made this workaround.
One may even save the new clustergram code as clustergramCM such that you can draw cgram in both ways.
A figure file is saved. When several lines are intersected, I want to make one of the line visible. How should I modify the different layer of the lines without re-plotting the figure?
Use uistack (see doc). For example, after:
figure
hold on
hblue=plot([1 2],[3 4],'b','LineWidth',5);
hred=plot([1 2],[4 3],'r','LineWidth',5);
the red line is on top (and the blue line would not be seen if the the red line covered it). Then, if you use uistack(hblue,'top'), the blue line is brought to the top. Other options to reorder plots, instead of top, are up, down, and bottom. You can optionally specify the number of steps up or down (e.g. uistack(h,'up',2) to move a handle two layers up - though no need in my simple example).
If, as you say, the 'figure file is saved', and you don't have the handles for the plots, (hblue and hred in my example), after loading the plot, you can get the handles using get(gca,'children').
If I understood you correctly, try to use hold on before plotting...