pgf/tikz: String Symbols as Input Coordinates - string

I'm new to pgf so i was trying out some examples from the pgfplot manual. One example is especially relevant for my current task but, alas, it would not compile.
Here is the code:
\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[symbolic x coords={a,b,c,d,e,f,g,h,i}]
\addplot+[smooth] coordinates {
(a,42)
(b,50)
(c,80)
(f,60)
(g,62)
(i,90)};
\end{axis}
\end{tikzpicture}
\end{document}
the compiler quits with the following error:
! Package PGF Math Error: Could not parse input 'a' as a floating point number,
sorry. The unreadable part was near 'a'..
I have no clue how to correct this behavior. Other plots (smooth, scatter, bar), which contain only numerical data compile fine.
Could anybody give me a hint?
Cheers
K.

You need to include this in the preamble:
\pgfplotsset{xticklabel={\tick},scaled x ticks=false}
\pgfplotsset{plot coordinates/math parser=false}
I had problems with this command when I tried to use it (specifically the "plot coordinates/math parser"), but then I updated the package pgfplots and it all worked.

Related

The x and y axis scaling in Contour plot

When I make a contour plot with Python, I have been using a set_aspect function. Because this allows me to avoid image/contour-lines distortion caused by changing both axis.
: for example, ax1.set_aspect('equal', 'box-forced')
But, I just found that the option 'box-forced' is not valid in Python3.
So my question is, is there any alternative of the 'box-forced' option in Python3? I want exactly the same effect as the ax1.set_aspect('equal', 'box-forced') in Python2.
Thanks!
I just found that there is a function plt.axis('scaled').
It seems that this does what I wanted in a recent version (3.7) of Python3.
You can try this one from the official documentation that I found in as my first recommended page:
https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_aspect.html
I'm not sure what you're trying to accomplish here exactly, but you could try the following:
ax1.set_aspect(aspect='equal', adjustable='box')
You could also check the following link which is for the set_adjustable method:
https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_anchor.html#matplotlib.axes.Axes.set_anchor
Hope this helps. Good luck!

What does square bracket mean in python paramters

Hello I'm new to python and I'm trying to learn OpenCV.
When I check the API references for OpenCV I came across this types of parameter description.
cv2.imread(filepath[, flags])
What does the "[, flags]" part mean? I know it takes in two variable, which is filepath and flags, but I don't know the meaning of the square bracket.
Any help is appreciated!

Referencing Figures in Latex

I am currently writing my thesis in greek and whenever I try to reference a figure I get the following in my text:
[;;]
This is the code I wrote:
\begin{figure}[h]
\label{ fig:image1}
\includegraphics[width=1\textwidth]{image1}
\caption{Απεικόνιση τρόπου κληρονομικότητας}
\end{figure}
And I call the ref by writing: {\ref{fig:{image1}}.
How do I fix this?
There is a simple rule in latex \caption should always come before \label [1]. So the code you write becomes:
\begin{figure}[h]
\includegraphics[width=1\textwidth]{image1}
\caption{Απεικόνιση τρόπου κληρονομικότητας}
\label{fig:image1}
\end{figure}
Also, you were referring to the image incorrectly.
and you can refer it using \ref{fig:image1} to get the correct reference.
This will work well, as the key you use for \label is the key you use for \ref.
References
[1] https://tex.stackexchange.com/questions/32325/why-does-an-environments-label-have-to-appear-after-the-caption

How to place latex-like mathematical formulas (e.g. via mathjax) in Haskell Diagrams?

I am attempting to place latex-style math formulas into a haskell diagram.
The documentation pages
http://projects.haskell.org/diagrams/doc/manual.html#essential-concepts
and
http://projects.haskell.org/diagrams/doc/tutorials.html
suggest that one can use something called 'mathjax' to achieve this.
Is there an explanation or example somewhere of how to actually code this?
Attempting to follow the documentation at those links, my best guess for how would be something like:
mathDiagram :: Diagram B
mathDiagram = stroke $ textSVG "`2 + \sqrt{\pi}`:math:" 1
But this of course gives an error:
induction.hs:13:35: error:
lexical error in string/character literal at character 's'
You can do this using the diagrams-pgf backend. Just use the text function and put dollar signs around your text. Also, see here for an explanation of how to include diagrams in a LaTeX document: http://projects.haskell.org/diagrams/doc/latex.html .

how to plot a graph using haskell graphViz

I'm planning to draw a graph using Haskell graphViz. I'm new to haskell, so this is quite difficult for me. Can someone show me a simple example ? I need a very simple example actually, so that I can understand it and use it in the scenario I'm working on
I get the above error on trying to install chart-cairo. I saw some examples on the internet and all of them requires chart-cairo. any idea how to resolve it ?
*EDITED"
The output that I get after executing the code given by https://stackoverflow.com/users/2827654/jamshidh
(This addresses your original question, described in the title, and doesn't go into the problems installing chart-cairo or chart, etc, which really should be spun out into different questions)....
The graphviz package includes some example graphs in module Data.Graph.Inductive.Example that can be used to get you up and running. You can see the list of included graphs at http://hackage.haskell.org/package/fgl-5.3/docs/Data-Graph-Inductive-Example.html.... I will use one called clr479.
Once you have a graph, you can convert it to an internal structure representing the dot format using graphToDot. Note that you will need to supply some parameters, which are described in http://hackage.haskell.org/package/graphviz-2999.11.0.0/docs/Data-GraphViz.html. Just to get up and running, I will use the supplied nonClusteredParams.
let graphInDotFormat = graphToDot nonClusteredParams clr479
Then, you will need to convert this to text suitable for input to the dot program. You can do this with renderDot . toDot
let outputText = renderDot $ toDot graphInDotFormat
and, as usual, you need to convert text to string to use putStrLn (don't just use show, as it will include quotes and escape sequences, which dot will not understand)
putStrLn $ unpack outputText
Putting this all together, the final program createDotFile.hs would be
import Data.Text.Lazy
import Data.GraphViz
import Data.Graph.Inductive.Example
import Data.GraphViz.Printing
main = putStrLn $ unpack $ renderDot $ toDot $ graphToDot nonClusteredParams clr479
Compile using ghc createDotFile.hs (remember to cabal install the required packages, as well as graphviz itself if you want to do anything with the output). On the commandline, you can now pipe the output of this program to dot, which will convert this to a usual format.... For instance, here I convert to svg
./createDotFile | dot -Tsvg > graph.svg
which on my linux box can be viewed by typing
eog graph.svg
Edit-
To clarify, the output of the haskell program needs to be provided as an input to GraphViz. The msi file to install graphviz on windows here http://www.graphviz.org/Download_windows.php.

Resources