I want to write the following in one line, rather than breaking it up by creating a circle node first and define a few points.
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{angles,through,calc,intersections}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
% want the following to work in one-line
\coordinate[label={below:$E$}](E) at (intersection of {(0,-3) circle[through=(-8, -3.6)]} and (-8,-3.5)--(8,-3.5));
\end{tikzpicture}
\end{document}
Related
I am plotting as follows:
plot for [i=1:n] word(fnames,i) ... with lines ,\
'otherfile.csv' ... with linepoints
I need otherfile.csv to be on top of word(fnames,n), on top of word(fnames,n-1), ... on top of word(fnames,1), but the resulting order is just the other way around.
So I am looking for a way of either reversing the order of lines being drawn or an expression like [i=n:-1:1] both of which I was unable to find.
Many thanks in advance!
Update
I accepted Erics answer below, but I will rather use [i=n:1:-1] as suggested by maij in a comment below for this approach does not require me to adapt the arguments of word occurrences in the plot command.
What about?
plot 'otherfile.csv' ... with linepoints,\
for [i=1:n] word(fnames,n-i+1) ... with lines
While looking through the Snap.svg tutorial, I came across the following line of code that made me do a double take:
// Now lets create pattern
var p = s.path("M10-5-10,15M15,0,0,15M0-5-20,15")
What is M10-5-10,15? At first, I thought it may have been some kind of coordinate-range syntax, but that wouldn't really make much sense in this case, and I couldn't find anything remotely close to that in the SVG path spec. I also couldn't find anything of note in the Snap.svg docs.
Interestingly enough, that code does seem to draw the desired pattern...
The simplest answer is often the right one. There is no special syntax - the coordinates are just concatenated together with no white space.
The clue is the command: M is the moveto command, which doesn't normally draw anything. If you look in the spec, however, you'll notice the following:
If a moveto is followed by multiple pairs of coordinates, the
subsequent pairs are treated as implicit lineto commands.
So, a moveto can actually have multiple coordinate pairs, and anything after the first pair is treated as a lineto command. The mystery syntax is, in reality, just a concise (but less readable) way of writing M10,-5 -10,15 M15,0 0,15 M0,-5 -20,15, the hyphens being the negative signs.
Simply looking at the SVG path grammar also shows quite clearly that the arguments to moveto are coordinate-pairs, and coordinates are simple numbers.
I suppose the key thing to take away is that SVG paths don't really need whitespace or commas, unless the numbers would be ambiguous without them.
I want to generate a gnuplot plot command programmatically, like:
plotline = sprintf("'datafile1.dat' using %d:3 with points, '%s' using %d:3 with points",i,targfile,i)
plot plotline
Where 'plotline' in the second line is expanded to produce and execute a full command like:
plot 'datafile1.dat' using 8:3 with points, 'datafile2.dat' using 8:3 with points
I want to do this in order to echo 'plotline' in the terminal and so be certain exactly what is being shown while cycling through a set of columns / datafiles / whatever inside a loop in a gnuplot script.
Is there / what is the syntax to do this, or can you suggest another approach to report the plot command as executed (without splitting into a plot command and a separate set of commands to report the current variable states).
Thanks!
In order to construct such a plot command from some strings, you can use eval to execute the commands contained in a string:
plotline = 'x title "mytitle"'
eval('plot '.plotline)
Alternatively you can use set macros:
set macros
plotline = 'x title "mytitle"'
plot #plotline
This replaces #plotline with the content of the string variable plotline before executing the command. Using plot plotline interpretes the content of plotline as file name. Note, that as of version 4.6 macros don't work properly in loops, but eval works fine.
BTW: If you don't specify your own title, then the actual plot statement is written in the plot legend. But that can't be written to the terminal output.
I've been using Emacs for a while now and am trying out Icicles. When I run the sequence of commands
C-c`\([a-z]*\)
S-TAB
C-| x\1y
it transforms the scratch buffer from
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
to
;; Xy xy xy xy xy xy xy'xy xy xy xy, xy xy Xy xy.
;; Xy xy xy xy xy xy xy, xy xy xy xy XY-xy XY-xy,
;; xy xy xy xy xy xy xy'xy xy xy.
My understanding is that it should instead attach an 'x' to the start of each word and a 'y' to the end of each word. What am I doing wrong here? I have tried this with emacs -Q and gotten the same results. Also, icicle-search-replace-literally-flag is unchanged from its default value of nil. What am I doing wrong? Thanks!
Edit: Sorry, I omitted the group in the regexp in the original post; however, I did use it in the test and still get the same result.
I do not use icicles but the effect is reproducible with the ordinary query-replace-regexp.
The problem is that you just do not define any group in your regular expression which you refer to in the replacement. Therefore the group reference \1 in the replacement string is empty.
Furthermore, you should use [a-z]+ instead of [a-z]* since [a-z]* also matches the empty string what you probably do not want.
To put the stuff you want to refer to into a group wrap it by paranthesis \(\). In your example the regular expression would look like \([a-z]+\). With this regular expression you can directly use your replacement string.
The alternative is to leave the regular expression as it is and refer to the whole match with \& instead of \1 in your replacement string.
Be sure that your version of file icicles-cmd2.el is dated after 2013-12-10. I fixed a bug wrt \N replacements on that date.
Other suggestions:
Proceed slowly, rather than immediately jumping into complex replacements etc. Icicles search and replacement are different from what you might be used to or expect.
Check the current values of all of the user options that affect Icicles search and replacement.
Short question:
How do I display the _ (underscore) character in a title in gnuplot that is assigned from a variable name in gnuplot?
Details:
I have something like the following code:
items = "foo_abc foo_bcd bar_def"
do for [item in items] {
set title item
set output item.eps
plot item."-input.txt" using 1:2 title item with linespoints
}
This works fine with gnuplot except that the title get changed from foo_abc to fooabc. I don't know if I want to use an escape character because I don't want that to be in the file name. I've tried a couple of different options with single vs. double quotes but I haven't found what I need yet.
Instead of foo_abc, write foo\\\_abc.
Most gnuplot commands which generate labels accept a noenhanced keyword which will prevent gnuplot from using enhanced text for just that string. In this case, it should be sufficient to just do:
set title item noenhanced
An alternative is to create a function which will remove the unwanted text from the string when passing it to set output:
remove(x,s)=(i0=strstrt(s,x),i0 ? remove(x,s[:i0-1].s[i0+strlen(x):]):s)
# Makes me wish gnuplot syntax was more pythonic :-p
#TODO: Write a `replace` function :-). These just might go into my ".gnuplot" file...
I use an inline function to find the index of the first occurrence of x in the string s. I then remove that occurrence via string concatenation and slicing and recursively call the function again to remove the next occurence. If the index isn't found (strstrt returns 0) then we just return the string that was put in. Now you can do:
set output remove('\',item)
set title item
The underscore comes from treating titles as "enhanced text". Turn that off using
set key noenhanced
If you are using the enhanced eps terminal, that is the reason you need to escape the underscore in the first place. There was another related question today which explains the issue a bit. When you set the terminal, try:
set terminal postscript noenhanced <whatever else here...>
That works for me (Arch linux, gnuplot 4.7.0). If the enhanced terminal is essential, below is a partial solution I found. The assumption is that the underscore always appears in the same place in the string.
set terminal postscript enhanced
items = 'foo\_abc foo\_bcd bar\_def'
do for [item in items] {
set output item[1:3].item[5:*].'.eps'
set title item
plot sin(x)
}
This way you can escape the underscore and not have the \ appear in the filename. Note the use of single quotes for the 'items' string; see the previously linked question for details.
I had the same problem about the underscore in the title: such as I needed to write 4_3 subframe and I needed the enhanced postscript. The SIMPLEST way turned out to be from the adjacent post: ``If you are using the enhanced eps terminal, that is the reason you need to escape the underscore in the first place. There was another related question today which explains the issue a bit." - How is # produced in gnuplot?
So, I followed their advice and this worked:
plot 'LC.stats' u 3:4 ti "{/=15 1350 stars in C18 4\_3 subframe}" -
Double escape character before the underscore.