I'm trying to create a sort of "vortex" downward vector in my Tikzpicture diagram. I looked up similar code for bending vectors, but don't know how to particularly change the details too well. I attached an image of what I am trying to attain and drew it in with red. I would attach code, but the entire diagram is quite lengthy. If someone could explain more how to bend the vector in a particular direction.
You could use a plot of a trigonometric function to swirl down there:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{shapes,backgrounds}
\begin{document}
\begin{tikzpicture}
\newcommand\x{1}
\newcommand\y{1}
\draw [scale=1, domain=-360:2250, samples=1000, smooth, variable=\t, red, thick] plot ({\x+ sin(\t)*(1-\t*0.0003)}, {\y +cos(\t)*(.3-\t*0.0001)-\t*.001});
\end{tikzpicture}
\end{document}
The commands x and y can be used to set the absolute position of the figure. scale is for size. The other parts are of course variable as well but it takes some time pruning.
The code above results in the following:
Related
I want to add an additional tick to my plot in ggplot2, and used Solution 2 as described in the post Annotate ggplot with an extra tick and label.
It worked fine for me, giving the following result in R Studio:
But when I try to save the result using ggsave() to create the a .pdf, .ps, or .png file, the red number is cut off half like this:
I have the feeling that the inner plot is printed first and later the margins are plotted on top of this.
Anybody has a hint?
Thank you Z. Lin! I just had a grid.draw(g) instead of g <- grid.draw(g). This dot in R always activates my python brain region :)
Evening all.
I am stumped. I have an RMarkDown document within which I need to be able to loop over a chunk a number of times, once for each item in a list. THIS I can do readily and it all works bar one part...
I need to be able to build and display a formula which changes with each chunk iteration. Outside the chunk (i.e. directly in the document) this is simple, with;
\[\alpha = (k/(k-1)) * \frac{(Var(T_{P})-\sum Var)}{Var(T_{P})} \]
I would expect it to be something like...
cat("\\frac{(Var(T_{P})-\\sum Var)}{Var(T_{P})}")
BUT within the chunk this blows apart.
Can anyone shed light here?
Thanks
As baptiste points out it's the math-mode wrapping that makes the difference. Changing the line to cat("$\\frac{(Var(T_{P})-\\sum Var)}{Var(T_{P})}$") sorts it just lovely.
As a tip, using $$ centers the equation on the line which is also useful.
I have on ODE of the form $\frac{dy}{dx}=f(x,y)$ that I managed to plot its solution in Matlab.
I want to add "direction of progress arrows" to the curves.
The curves illustrated below are the paramteric plot of x(t) and y(t), each having 1500 steps.
The black arrow seen on left has been inserted using the "Insert Arrow" option from the figure's window.
I want to add arrows like those in the black and white picture attached.
Is there any way to do it? Any help would be appreciated.
Not sure if you ever figured this out, however, one solution, though not elegant, could be to use the Plot with Direction Function from the MATLAB FEx.
After computing your ODE solution, you could take various points and use the above Plot with Direction function from the FEx. Below is some pseudo code which describes what I am talking about.
[x_sol, y_sol] = ODE_METHOD(#fcn,...);
x_Points4Arrow = x_sol([...]);
y_Points4Arrow =
% Plot ODE solution
for ind = 1:numel(y_Points4Arrow)
| hold on
| Plot With Direction(x_Points4Arrow(ind), y_Points4Arrow(ind));
| hold off
end
% Modify axes and anything else
You could even modify that function to take in the Line Properties - or just modify the code if you only want one color.
Just wondering if it is possible to increase the size of the plot so that the nodes and edges can be more scattered over the plot.
Original plot:
What are expected:
I tried many parameters in the layout function such as area, niter, and so on, but all of them do not work. By the way, I am using 'igraph' package in R.
If you are referring to the actual size of the produced output (pdf, png, etc), you can configure it with the width and height parameters. Check this link for png,bpm, etc, and this link for PDF format.
A MWE is something like this:
png("mygraph.png", heigh=400, width=600)
#functions to plot your graph
dev.off()
If you are referring to the size of the graphic produced by the layout function, as #MrFlick referred, you should check the parameters of the particular layout you are using.
Hope it helps you.
In your second graph, it's obviously the graph can be divided into several clusters (or sections). If I understood you correctly, you want to have a layout that separates your clusters more visibly.
Then you can draw this by calculating a two-level layout:
First, calculate the layout of the graph in order to find a place for each cluster.
Second, calculate the layout in each cluster according to first step and plot nodes in the corresponding place.
I'm using plotrix package to draw circles.
And I don't get what is wrong with my code... :-(
I have three points. The first point (1,1) should be the center of the circle. The following two points (1,4) and (4,1) have the same distance/radius to the center.
So the circle in the plot should go through these points, right?
And I don't know why the circle looks wrong. Is there an explanation?
p1 <- c(1,1)
p2 <- c(4,1)
p3 <- c(1,4)
r <- sqrt(sum((p1-p2)^2))
plot(x=c(p1[1], p2[1], p3[1]),
y=c(p1[2], p2[2], p3[2]),
ylim=c(-5,5), xlim=c(-5,5))
draw.circle(x=p1[1], y=p1[2], radius=(r))
abline(v=-5:5, col="#0000FF66")
abline(h=-5:5, col="#0000FF66")
Take a look at the produced output here
As #Baptiste says above, you can use plot(...,asp=1). This will only work if your x and y ranges happen to be the same, though (because it sets the physical aspect ratio of your plot to 1). Otherwise, you probably want to use the eqscplot function from the MASS package. A similar issue arises whenever you try to do careful plots of geometric objects, e.g. Drawing non-intersecting circles
This plot is produced by substituting MASS::eqscplot for plot in your code above:
Note that depending on the details of what R thinks about your monitor configuration etc., the circle may look a bit squashed (even though it goes through the points) when you plot in R's graphics window -- it did for me -- but should look OK in the graphical output.