Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help lines grid with coordinates #760

Closed
dbitouze opened this issue Oct 25, 2019 · 21 comments
Closed

Help lines grid with coordinates #760

dbitouze opened this issue Oct 25, 2019 · 21 comments

Comments

@dbitouze
Copy link

Would be nice to provide an option that makes possible to easily add coordinates to an help lines grid, as in this answer on SE.

@hmenke
Copy link
Member

hmenke commented Oct 27, 2019

Use pgfplots.

For example:

\documentclass{article}    
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        xmin=-2,xmax=5,
        ymin=-2,ymax=5,
        xtick={-2,...,5},
        ytick={-2,...,5},
        minor tick num=4,
        ticks=both,
        grid=both,
        ]

    \end{axis}
\end{tikzpicture}
\end{document}

@dbitouze

This comment has been minimized.

@hmenke
Copy link
Member

hmenke commented Oct 28, 2019

Still I believe that pgfplots covers 80% of all use-cases. If you really want to have this, encapulate it in a TikZ library and open a pull request.

@dbitouze
Copy link
Author

dbitouze commented Oct 28, 2019

If you really want to have this, encapsulate it in a TikZ library and open a pull request.

I'm not enough a TikZ-expert to do this in a robust way, nor in the rules of art. That's the reason I requested this feature. Hence would be nice for this feature request to not be closed.

@Mo-Gul
Copy link
Contributor

Mo-Gul commented Oct 29, 2019

Seeing your examples I just remembered that something similar is done to be able to add annotations to images in the tikz-imagelabels package. Maybe this is a good start to create a similar library for TikZ?

@dbitouze
Copy link
Author

@Mo-Gul Many thanks for this reminder! I was aware of this package but was unable to remember its name and find it. Nevertheless:

  • having this as a TikZ built-in feature would be nice,
  • this package is dedicated to images and doesn't apply to e.g. listings (from the listings package) whereas a node of a tikzpicture is perfectly able to contain verbatim material such as a listing.

@hmenke
Copy link
Member

hmenke commented Oct 29, 2019

  • having this as a TikZ built-in feature would be nice,

Why? We already know of two packages (pgfplots, tikz-imagelabels) that implement very similar functionality. Wouldn't it be better to add the requested feature to one of these packages, rather than having yet another, slightly different, but also incomplete and incompatible implementation?

Mandatory XKCD in that context:
https://xkcd.com/927/

@dbitouze
Copy link
Author

We already know of two packages (pgfplots, tikz-imagelabels) that implement very similar functionality.

  • It is not clear pgfplots actually implements this functionality in an easy to use and simple way.
  • tikz-imagelabels only applies to images.

@Mo-Gul

This comment has been minimized.

@dbitouze
Copy link
Author

Very nice solution indeed, which could be subject to a library! Except maybe that loading pgfplots just for this is a bit overkilling, isn't it?

@hmenke hmenke added this to the 3.1.5 milestone Nov 3, 2019
@hmenke hmenke removed this from the 3.1.5 milestone Nov 29, 2019
@hmenke
Copy link
Member

hmenke commented Feb 7, 2020

I have reopened this issue and applied the “help wanted” tag to show that if you want this feature, you (or someone else) will have to implement this.

@hmenke hmenke reopened this Feb 7, 2020
@dbitouze
Copy link
Author

dbitouze commented Jun 8, 2020

@tallmarmot:

It would be interesting to know what kind of ticks you have in mind.

What I have in mind is the grids as provided by PSTricks (often temporary used), which are very useful when one creates a draw:

\documentclass{article}
\usepackage{pstricks}
\thispagestyle{empty}
\begin{document}
\psgrid(0,0)(-1,-1)(3,2)
\end{document}

test

@hmenke
Copy link
Member

hmenke commented Jun 8, 2020

@dbitouze Looks like you have a solution already. Just place that in a node at the origin and you're good to go.

\documentclass{article}
\usepackage{pstricks}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \node at (0,0) {\psgrid(0,0)(-1,-1)(3,2)};
    \draw[thick,red] (0,0) to (2,2);
\end{tikzpicture}
\end{document}

test

@dbitouze
Copy link
Author

dbitouze commented Jun 9, 2020

@hmenke That's not a suitable solution: loading pstricks just for a grid is overkilling and, above all, this would make impossible to compile with pdftex or luatex engines (unless using the not very handy auto-pst-pdf package and run with the -shell-escape option).

@hmenke
Copy link
Member

hmenke commented Jun 9, 2020

Well, we have proposed multiple disparate solutions, none of which you have deemed satisfactory. Also, no volunteers are forthcoming for the library implementation that you demand. The lack of interest from the community in this feature led me to close this request.

Further, in my opinion, PGF/TikZ should not provide any pre-made solutions. Instead, I think of it as a toolbox with generic mechanisms that allow the user to create specific solutions like this one.

@dbitouze
Copy link
Author

led me to close this request.

Too bad!

Further, in my opinion, PGF/TikZ should not provide any pre-made solutions. Instead, I think of it as a toolbox with generic mechanisms that allow the user to create specific solutions like this one.

Doesn't TikZ provide the pre-made grid path and the help lines style? IMO, they only lack the grid labels that let the user immediately know which are the coordinates of a given point of the grid.

@hmenke
Copy link
Member

hmenke commented Jun 10, 2020

Yes, indeed TikZ provides grid and help lines as the tools and leaves it to the user to combine them into specific solutions, such as the one you wish.

@dbitouze
Copy link
Author

Sorry to insist. IMO, grids with labels are not that specific. Comparatively, PSTricks considers grids with labels as basic graphics objects.

@hmenke
Copy link
Member

hmenke commented Jun 10, 2020

Then use PSTricks.

@dbitouze
Copy link
Author

If I insist, it is because I do prefer TikZ over PSTricks nowadays: much more possibilities and, above all, it does work with all the current engines. My request is just a feature request, no need to be rude.

@dbitouze
Copy link
Author

OK, sorry: not rude but rather blunt :)

What is inconvenient IMO is that help lines often are only partially helpful. In the following example (randomly selected), as in many of the documentation's ones, one has to check the code in order to figure out where is the point (0,0) (and that's worse if (0,0) is in the middle of the grid):
test

By contrast, the following picture would be immediately understood.
test

And, when one has to build a complex picture, with many points, the labels would be helpful in order to position them. OK, I know TikZ provides the relative positions of the nodes but, anyway.

Code of the second figure

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (3,2);
\draw
(0,0) -- (1,1) -- (1,0);
\draw[scale=2,blue]
(0,0) -- (1,1) -- (1,0);
\draw[scale around={2:(1,1)},red] (0,0) -- (1,1) -- (1,0);
% Grid labels added
\foreach \pos in {0,1,2,3}
\draw[shift={(\pos,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\pos$};
\foreach \pos in {0,1,2}
\draw[shift={(0,\pos)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\pos$};
\end{tikzpicture}
\end{document}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants