Side comment between equation (LEFT) - curve

I found the following page, which is almost what I want https://tex.stackexchange.com/questions/344379/side-comment-between-equation/344386#344386
Can someone explain me what change I have to do such that I can put this arrow on the left of my equation? Since this is what I have right now wrong arrow
Thanks in advance

You need to:
move the tikzmarks to the other side of the equations ;
invert the curve: .. controls +(-1,0) and +(-1,0) .. ;
readjust the starting positions: \newcommand\sidecomment[5][-0.5,0.1]% ;
move and align the text attached to the curve to the opposing side: node[left,align=right]{#5}.
Here's the result:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark,arrows,calc}
\usepackage{amsmath}
\newcommand\sidecomment[5][-0.5,0.1]%
{\begin{tikzpicture}[remember picture,overlay]
\draw[-stealth',thick]
($({pic cs:#4}|-{pic cs:#2})+(#1)$)
.. controls +(-1,0) and +(-1,0) ..
node[left,align=right]{#5}
($({pic cs:#4}|-{pic cs:#3})+(#1)$);
\end{tikzpicture}%
}
\begin{document}
\begin{align*}
\tikzmark{a}\beta_1^*
&= \frac{\sum_{i=1}^n(x_i^*-\hat x^*)y_i^*}{\sum_{i=1}^n(x_i^*-\hat x^*)^2}\\
\tikzmark{b}&= \frac{\sum_{i=1}^n(w_2x_i-w_2\hat x)w_1y_i}{\sum_{i=1}^n(w_2x_i-w_2\hat x)^2}
\end{align*}
\sidecomment{a}{b}{b}{since $y_i^*=w_1y_i$\\and $x_i*=w_2x_i$}
\end{document}

Related

Subfigures in latex never shrinks to be on one row (pfd file)

I'm trying to adjust two subfigures into one row. This is my code:
\begin{figure}[ht]
\centering
\caption{Migration rates and nightlights in Albania in 1992-1995}
\begin{subfigure}[a]{0.3\textwidth}
\caption{Emigration rate before 1995 at the municipality level}
\label{fig: migration_rate}
\includegraphics[width=\linewidth, trim = 5cm 0cm 5cm 0cm, clip]{Figures/migration_rate.pdf}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\caption{Night luminosity in 1992}
\label{fig: nighlights}
\includegraphics[width=\linewidth, trim = 5cm 0cm 5cm 0cm, clip]{Figures/nightlight.pdf}
\end{subfigure}
\caption*{\footnotesize{\textbf{Notes}:}}.
\end{figure}
enter image description here
Even if I shrink the subfigure to tiny size (for example {0.01\textwidth}), the two always appear in one column. I have deep blank space on the left and right of both figures that I have tried to trim. Including or excluding "trim" does not change much.
How do I get the two into one row?
Thank you!

Seaborn: Place the y-label in a line with the points on the coordinate axis

I want to place the y-label in the left upper corner in line with the points on the coordinate axis. The label should replace the axes ticks in that area.
Here is an example from a paper that I read:
I found a lot of information on how to move the label to the top left corner. However, how do I remove the ticks and move the label closer to the axes?
The best solution that I found:
# style
plt.figure(figsize=(8,8))
sns.set_style("white")
sns.set_context("paper", font_scale=1.6)
# plot
sn_dis1 = sns.displot(idx_pix_count_pd, hue='Dataset', x="Size", fill=True, palette='bwr', kind="hist", bins=500)
# y-achses
axes = sn_dis1.axes.flatten()
axes[0].set_ylabel("Count", fontsize=16)
axes[0].yaxis.set_label_coords(.0, .9)
The approach proposed by Trenton (Edit: Who delete his comment to my original question) did not work for me as the text is horizontal vertically. But I learned something from it and am sure that you somehow can make it work like that.
# style
plt.figure(figsize=(8,8))
sns.set_style("white")
sns.set_context("paper", font_scale=1.6)
# plot
sn_dis1 = sns.displot(idx_pix_count_pd, hue='Dataset', x="Size", fill=True, palette='bwr', kind="hist", bins=500)
# y-achses
ticks = range(8)
labels= list(range(7)) + ['Density']
axes = sn_dis1.axes.flatten()
axes[0].set_yticklabels(labels)
# do not show default label
axes[0].get_yaxis().get_label().set_visible(False)

How , to avoid vertical straight to overlap the others labels in LaTeX chronosys

I´m trying to follow the documentation of chronosys LaTeX package, to solve my issue to avoid vertical straight to overlap the others labels, but I cannot go ahead!
My code in LaTeX is:
\documentclass[a4paper,12pt]{article}
\usepackage{chronology}
\usepackage{chronosys}
\begin{document}
\startchronology[startyear=1980]
\chronoevent{1982}{\rotatebox{90}{\textbf{ARCH} $\Rightarrow$ \newline Robert Engle~\cite{engle}}}
\chronoevent[markdepth=50pt, ifcolorbox = true, colorbox = white]{1986}{\rotatebox{90}{\textbf{GARCH} $\Rightarrow$ \textit{Tim Bollerslev}~\cite{bollerslev}}}
\chronoevent[markdepth=250pt]{1986}{\rotatebox{90}{\textbf{IGARCH} $\Rightarrow$ \textit{Tim Bollerslev e R. Engle}~\cite{englebollerslev}}}
\stopchronology
\end{document}
That is the result:
I tryed to insert colorbox=white, but I don´t know if I am is in the correct way...
Change the order of the events, so you won't draw the bottom even on top of the other:
\documentclass[a4paper,12pt]{article}
%\usepackage{chronology}
\usepackage{chronosys}
\begin{document}
\startchronology[startyear=1980]
\chronoevent{1982}{\rotatebox{90}{\textbf{ARCH} $\Rightarrow$ \newline Robert Engle~\cite{engle}}}
\chronoevent[markdepth=250pt]{1986}{\rotatebox{90}{\textbf{IGARCH} $\Rightarrow$ \textit{Tim Bollerslev e R. Engle}~\cite{englebollerslev}}}
\chronoevent[markdepth=50pt]{1986}{\rotatebox{90}{\textbf{GARCH} $\Rightarrow$ \textit{Tim Bollerslev}~\cite{bollerslev}}}
\stopchronology
\end{document}

How to block possibility to edit/drag impoly in matlab?

I create a polygon on image_area in matlab.
I used impoly.
But after creation polygon.
I need to block possibility to move and drag impoly (ROI is already created).
I don't know how I should do it ?
I would appreciate for any help please.
You can set the makeConstrainToRectFcn such that it is a rectangle encompassing your ROI, then whenever you try to move the latter it won't work. You can also, after creating the ROI, set the setVerticesDraggable method to false in order to prevent vertices from being dragged.
Sample code (adapted from example by the Mathworks):
clc
clear
figure
imshow('gantrycrane.png');
h = impoly(gca, [188,30; 189,142; 93,141; 13,41; 14,29]);
%// Get currentposition
Pos = getPosition(h);
%// Prevent draggable vertices
setVerticesDraggable(h,0);
%// Set up rectangle to prvent movement of ROI
fcn = makeConstrainToRectFcn('impoly', [min(Pos(:,1)) max(Pos(:,1))], [min(Pos(:,2)) max(Pos(:,2))]);
%// Apply function
h.setPositionConstraintFcn(fcn);
which results in this kind of situation (with red rectangle for illustration):

Print image to pdf without margin using Matlab

I'm trying to use the answers I found in these questions:
How to save a plot into a PDF file without a large margin around
Get rid of the white space around matlab figure's pdf output
External source
to print a matlab plot to pdf without having the white margins included.
However using this code:
function saveTightFigure( h, outfilename, orientation )
% SAVETIGHTFIGURE(H,OUTFILENAME) Saves figure H in file OUTFILENAME without
% the white space around it.
%
% by ``a grad student"
% http://tipstrickshowtos.blogspot.com/2010/08/how-to-get-rid-of-white-margin-in.html
% get the current axes
ax = get(h, 'CurrentAxes');
% make it tight
ti = get(ax,'TightInset');
set(ax,'Position',[ti(1) ti(2) 1-ti(3)-ti(1) 1-ti(4)-ti(2)]);
% adjust the papersize
set(ax,'units','centimeters');
pos = get(ax,'Position');
ti = get(ax,'TightInset');
set(h, 'PaperUnits','centimeters');
set(h, 'PaperSize', [pos(3)+ti(1)+ti(3) pos(4)+ti(2)+ti(4)]);
set(h, 'PaperPositionMode', 'manual');
set(h, 'PaperPosition',[0 0 pos(3)+ti(1)+ti(3) pos(4)+ti(2)+ti(4)]);
% save it
%saveas(h,outfilename);
if( orientation == 1)
orient portrait
else
orient landscape
end
print( '-dpdf', outfilename );
end
Results in this output:
As you can see the 'PaperSize' seems to be set not properly. Any idea of possible fixes?
NOTE
If I change the orientation between landscape and portrait the result is the same, simply the image is chopped in a different way.
However if I save the image with the saveas(h,outfilename); instruction the correct output is produced.
Why is this? And what is the difference between the two saving instructions?
Alltogether the answers you mentioned offer a lot of approaches, but most of them didn't worked for me neither. Most of them screw up your papersize when you want to get the tight inset, the only which worked for me was:
set(axes_handle,'LooseInset',get(axes_handle,'TightInset'));
I finally wrote a function, where I specify the exact height and width of the output figure on paper, and the margin I want (or just set it to zero). Be aware that you also need to pass the axis handle. Maybe this functions works for you also.
function saveFigure( fig_handle, axes_handle, name , height , width , margin)
set(axes_handle,'LooseInset',get(axes_handle,'TightInset'));
set(fig_handle, 'Units','centimeters','PaperUnits','centimeters')
% the last two parameters of 'Position' define the figure size
set(fig_handle,'Position',[-margin -margin width height],...
'PaperPosition',[0 0 width+margin height+margin],...
'PaperSize',[width+margin height+margin],...
'PaperPositionMode','auto',...
'InvertHardcopy', 'on',...
'Renderer','painters'... %recommended if there are no alphamaps
);
saveas(fig_handle,name,'pdf')
end
Edit: if you use painters as renderer saveas and print should produce similar results. For jpegs print is preferable as you can specify the resolution.

Resources