How to scale down the size of tick on an axis of graph in Tikz
How to scale down the size of tick (j-1, j and j+1) of a graph in Tikz
?
Moreover, as I don't have a lot of experience with Tikz
, if there is a more standard/efficient way of writing the whole graph, I'm obviously glad to learn!
I obtained this graph by modifying a an example that I found on Texample.net
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {$i$}
-| (xaxis -| c) node[below] {$j-1$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i$}
-| (xaxis -| d) node[below] {$j$};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i+1$}
-| (xaxis -| d) node[below] {$j$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i$}
-| (xaxis -| d) node[below] {$j+1$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
tikz-pgf graphics axis
add a comment |
How to scale down the size of tick (j-1, j and j+1) of a graph in Tikz
?
Moreover, as I don't have a lot of experience with Tikz
, if there is a more standard/efficient way of writing the whole graph, I'm obviously glad to learn!
I obtained this graph by modifying a an example that I found on Texample.net
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {$i$}
-| (xaxis -| c) node[below] {$j-1$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i$}
-| (xaxis -| d) node[below] {$j$};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i+1$}
-| (xaxis -| d) node[below] {$j$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i$}
-| (xaxis -| d) node[below] {$j+1$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
tikz-pgf graphics axis
add a comment |
How to scale down the size of tick (j-1, j and j+1) of a graph in Tikz
?
Moreover, as I don't have a lot of experience with Tikz
, if there is a more standard/efficient way of writing the whole graph, I'm obviously glad to learn!
I obtained this graph by modifying a an example that I found on Texample.net
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {$i$}
-| (xaxis -| c) node[below] {$j-1$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i$}
-| (xaxis -| d) node[below] {$j$};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i+1$}
-| (xaxis -| d) node[below] {$j$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i$}
-| (xaxis -| d) node[below] {$j+1$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
tikz-pgf graphics axis
How to scale down the size of tick (j-1, j and j+1) of a graph in Tikz
?
Moreover, as I don't have a lot of experience with Tikz
, if there is a more standard/efficient way of writing the whole graph, I'm obviously glad to learn!
I obtained this graph by modifying a an example that I found on Texample.net
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {$i$}
-| (xaxis -| c) node[below] {$j-1$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i$}
-| (xaxis -| d) node[below] {$j$};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i+1$}
-| (xaxis -| d) node[below] {$j$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$i$}
-| (xaxis -| d) node[below] {$j+1$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
tikz-pgf graphics axis
tikz-pgf graphics axis
edited 1 hour ago
asked 1 hour ago
ecjb
1516
1516
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I put some opacity in the grid. In my opinion, they should also put the red dots in the foreground to hide the dotted lines that invade the dots. But I don't know if you want this.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {}
-| (xaxis -| c) node[below] {$scriptstyle{j-1}$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i}$}
-| (xaxis -| d) node[below] {};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i+1}$}
-| (xaxis -| d) node[below] {$scriptstyle{j}$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {}
-| (xaxis -| d) node[below] {$scriptstyle{j+1}$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
3
Hi Sebastiano, happy new year! You could also addevery node/.style={scale = 0.7}
to scale down all nodes at once
– caverac
40 mins ago
@caverac Hi to you and a happy new year full of joy and serenity for you and your loved ones. You can make all the changes you want, I don't understand English very much :( especially in the questions without figures.
– Sebastiano
35 mins ago
1
Happy new year! thanks to Sebastiano and @caverac. Where in the code shouldevery node/.style={scale = 0.7}
be written?
– ecjb
35 mins ago
2
@ecjb It would be at the same location where you specify the scale, it would be something likebegin{tikzpicture}[scale = 0.7, every node/.style={scale = 0.7}]
. I think your answer is spot on Sebastiano, just wanted to give you another option :)
– caverac
33 mins ago
Please note thatscriptstyle
is a switch (just liketiny
orsmall
) and does not take an argument.
– samcarter
9 mins ago
add a comment |
If you don't mind that x and y will also become smaller, you could just use a smaller font size, e.g. by using scriptsize
before the tikzpicture
. This will also avoid the problem, that scaling elements that contain text will result in a suboptimal choice of letter shapes (see Why not scale elements that contain text for more information).
Another small problem: you print the labels for i
and j
three times above each other, depending on the rendering precision of your pdf viewer this can cause the font to look awkward, better only print it one time.
It would also be better, if you would choose unique names for your coordinates instead of re-using d
for 3 of them. This has the big advantage, that you can easily control the order in which you draw things. For example you can first draw the grid in the background, then the axis, the dashed lines and the red dots at the end.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begingroup
scriptsize
begin{tikzpicture}[scale=0.7]
% grid
draw [thin, gray] (0,0) grid (5,5);
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$} |- (5,0) node (xaxis) [right] {$x$};
% Coordinates
coordinate (a) at (2,2);
coordinate (b) at (3,2);
coordinate (c) at (3,3);
coordinate (d) at (4,2);
% Dashed lines
draw[dashed] (yaxis |- a) node[left] {} -| (xaxis -| a) node[below] {$j-1$};
draw[dashed] (yaxis |- b) node[left] {} -| (xaxis -| b) node[below] {};
draw[dashed] (yaxis |- c) node[left] {$i+1$} -| (xaxis -| c) node[below] {$j$};
draw[dashed] (yaxis |- d) node[left] {$i$} -| (xaxis -| d) node[below] {$j+1$};
% red dots
fill[red] (a) circle (3pt);
fill[red] (b) circle (3pt);
fill[red] (c) circle (3pt);
fill[red] (d) circle (3pt);
end{tikzpicture}
endgroup
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468114%2fhow-to-scale-down-the-size-of-tick-on-an-axis-of-graph-in-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I put some opacity in the grid. In my opinion, they should also put the red dots in the foreground to hide the dotted lines that invade the dots. But I don't know if you want this.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {}
-| (xaxis -| c) node[below] {$scriptstyle{j-1}$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i}$}
-| (xaxis -| d) node[below] {};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i+1}$}
-| (xaxis -| d) node[below] {$scriptstyle{j}$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {}
-| (xaxis -| d) node[below] {$scriptstyle{j+1}$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
3
Hi Sebastiano, happy new year! You could also addevery node/.style={scale = 0.7}
to scale down all nodes at once
– caverac
40 mins ago
@caverac Hi to you and a happy new year full of joy and serenity for you and your loved ones. You can make all the changes you want, I don't understand English very much :( especially in the questions without figures.
– Sebastiano
35 mins ago
1
Happy new year! thanks to Sebastiano and @caverac. Where in the code shouldevery node/.style={scale = 0.7}
be written?
– ecjb
35 mins ago
2
@ecjb It would be at the same location where you specify the scale, it would be something likebegin{tikzpicture}[scale = 0.7, every node/.style={scale = 0.7}]
. I think your answer is spot on Sebastiano, just wanted to give you another option :)
– caverac
33 mins ago
Please note thatscriptstyle
is a switch (just liketiny
orsmall
) and does not take an argument.
– samcarter
9 mins ago
add a comment |
I put some opacity in the grid. In my opinion, they should also put the red dots in the foreground to hide the dotted lines that invade the dots. But I don't know if you want this.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {}
-| (xaxis -| c) node[below] {$scriptstyle{j-1}$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i}$}
-| (xaxis -| d) node[below] {};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i+1}$}
-| (xaxis -| d) node[below] {$scriptstyle{j}$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {}
-| (xaxis -| d) node[below] {$scriptstyle{j+1}$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
3
Hi Sebastiano, happy new year! You could also addevery node/.style={scale = 0.7}
to scale down all nodes at once
– caverac
40 mins ago
@caverac Hi to you and a happy new year full of joy and serenity for you and your loved ones. You can make all the changes you want, I don't understand English very much :( especially in the questions without figures.
– Sebastiano
35 mins ago
1
Happy new year! thanks to Sebastiano and @caverac. Where in the code shouldevery node/.style={scale = 0.7}
be written?
– ecjb
35 mins ago
2
@ecjb It would be at the same location where you specify the scale, it would be something likebegin{tikzpicture}[scale = 0.7, every node/.style={scale = 0.7}]
. I think your answer is spot on Sebastiano, just wanted to give you another option :)
– caverac
33 mins ago
Please note thatscriptstyle
is a switch (just liketiny
orsmall
) and does not take an argument.
– samcarter
9 mins ago
add a comment |
I put some opacity in the grid. In my opinion, they should also put the red dots in the foreground to hide the dotted lines that invade the dots. But I don't know if you want this.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {}
-| (xaxis -| c) node[below] {$scriptstyle{j-1}$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i}$}
-| (xaxis -| d) node[below] {};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i+1}$}
-| (xaxis -| d) node[below] {$scriptstyle{j}$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {}
-| (xaxis -| d) node[below] {$scriptstyle{j+1}$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
I put some opacity in the grid. In my opinion, they should also put the red dots in the foreground to hide the dotted lines that invade the dots. But I don't know if you want this.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begin{tikzpicture}[scale = 0.7]
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
|- (5,0) node (xaxis) [right] {$x$};
coordinate (c) at (2,2);
fill[red] (c) circle (3pt);
draw[dashed] (yaxis |- c) node[left] {}
-| (xaxis -| c) node[below] {$scriptstyle{j-1}$};
coordinate (d) at (3,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i}$}
-| (xaxis -| d) node[below] {};
coordinate (d) at (3,3);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {$scriptstyle{i+1}$}
-| (xaxis -| d) node[below] {$scriptstyle{j}$};
coordinate (d) at (4,2);
fill[red] (d) circle (3pt);
draw[dashed] (yaxis |- d) node[left] {}
-| (xaxis -| d) node[below] {$scriptstyle{j+1}$};
draw [thin, gray] (0,0) grid (5,5);
end{tikzpicture}
end{document}
edited 37 mins ago
answered 54 mins ago
Sebastiano
9,00541756
9,00541756
3
Hi Sebastiano, happy new year! You could also addevery node/.style={scale = 0.7}
to scale down all nodes at once
– caverac
40 mins ago
@caverac Hi to you and a happy new year full of joy and serenity for you and your loved ones. You can make all the changes you want, I don't understand English very much :( especially in the questions without figures.
– Sebastiano
35 mins ago
1
Happy new year! thanks to Sebastiano and @caverac. Where in the code shouldevery node/.style={scale = 0.7}
be written?
– ecjb
35 mins ago
2
@ecjb It would be at the same location where you specify the scale, it would be something likebegin{tikzpicture}[scale = 0.7, every node/.style={scale = 0.7}]
. I think your answer is spot on Sebastiano, just wanted to give you another option :)
– caverac
33 mins ago
Please note thatscriptstyle
is a switch (just liketiny
orsmall
) and does not take an argument.
– samcarter
9 mins ago
add a comment |
3
Hi Sebastiano, happy new year! You could also addevery node/.style={scale = 0.7}
to scale down all nodes at once
– caverac
40 mins ago
@caverac Hi to you and a happy new year full of joy and serenity for you and your loved ones. You can make all the changes you want, I don't understand English very much :( especially in the questions without figures.
– Sebastiano
35 mins ago
1
Happy new year! thanks to Sebastiano and @caverac. Where in the code shouldevery node/.style={scale = 0.7}
be written?
– ecjb
35 mins ago
2
@ecjb It would be at the same location where you specify the scale, it would be something likebegin{tikzpicture}[scale = 0.7, every node/.style={scale = 0.7}]
. I think your answer is spot on Sebastiano, just wanted to give you another option :)
– caverac
33 mins ago
Please note thatscriptstyle
is a switch (just liketiny
orsmall
) and does not take an argument.
– samcarter
9 mins ago
3
3
Hi Sebastiano, happy new year! You could also add
every node/.style={scale = 0.7}
to scale down all nodes at once– caverac
40 mins ago
Hi Sebastiano, happy new year! You could also add
every node/.style={scale = 0.7}
to scale down all nodes at once– caverac
40 mins ago
@caverac Hi to you and a happy new year full of joy and serenity for you and your loved ones. You can make all the changes you want, I don't understand English very much :( especially in the questions without figures.
– Sebastiano
35 mins ago
@caverac Hi to you and a happy new year full of joy and serenity for you and your loved ones. You can make all the changes you want, I don't understand English very much :( especially in the questions without figures.
– Sebastiano
35 mins ago
1
1
Happy new year! thanks to Sebastiano and @caverac. Where in the code should
every node/.style={scale = 0.7}
be written?– ecjb
35 mins ago
Happy new year! thanks to Sebastiano and @caverac. Where in the code should
every node/.style={scale = 0.7}
be written?– ecjb
35 mins ago
2
2
@ecjb It would be at the same location where you specify the scale, it would be something like
begin{tikzpicture}[scale = 0.7, every node/.style={scale = 0.7}]
. I think your answer is spot on Sebastiano, just wanted to give you another option :)– caverac
33 mins ago
@ecjb It would be at the same location where you specify the scale, it would be something like
begin{tikzpicture}[scale = 0.7, every node/.style={scale = 0.7}]
. I think your answer is spot on Sebastiano, just wanted to give you another option :)– caverac
33 mins ago
Please note that
scriptstyle
is a switch (just like tiny
or small
) and does not take an argument.– samcarter
9 mins ago
Please note that
scriptstyle
is a switch (just like tiny
or small
) and does not take an argument.– samcarter
9 mins ago
add a comment |
If you don't mind that x and y will also become smaller, you could just use a smaller font size, e.g. by using scriptsize
before the tikzpicture
. This will also avoid the problem, that scaling elements that contain text will result in a suboptimal choice of letter shapes (see Why not scale elements that contain text for more information).
Another small problem: you print the labels for i
and j
three times above each other, depending on the rendering precision of your pdf viewer this can cause the font to look awkward, better only print it one time.
It would also be better, if you would choose unique names for your coordinates instead of re-using d
for 3 of them. This has the big advantage, that you can easily control the order in which you draw things. For example you can first draw the grid in the background, then the axis, the dashed lines and the red dots at the end.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begingroup
scriptsize
begin{tikzpicture}[scale=0.7]
% grid
draw [thin, gray] (0,0) grid (5,5);
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$} |- (5,0) node (xaxis) [right] {$x$};
% Coordinates
coordinate (a) at (2,2);
coordinate (b) at (3,2);
coordinate (c) at (3,3);
coordinate (d) at (4,2);
% Dashed lines
draw[dashed] (yaxis |- a) node[left] {} -| (xaxis -| a) node[below] {$j-1$};
draw[dashed] (yaxis |- b) node[left] {} -| (xaxis -| b) node[below] {};
draw[dashed] (yaxis |- c) node[left] {$i+1$} -| (xaxis -| c) node[below] {$j$};
draw[dashed] (yaxis |- d) node[left] {$i$} -| (xaxis -| d) node[below] {$j+1$};
% red dots
fill[red] (a) circle (3pt);
fill[red] (b) circle (3pt);
fill[red] (c) circle (3pt);
fill[red] (d) circle (3pt);
end{tikzpicture}
endgroup
end{document}
add a comment |
If you don't mind that x and y will also become smaller, you could just use a smaller font size, e.g. by using scriptsize
before the tikzpicture
. This will also avoid the problem, that scaling elements that contain text will result in a suboptimal choice of letter shapes (see Why not scale elements that contain text for more information).
Another small problem: you print the labels for i
and j
three times above each other, depending on the rendering precision of your pdf viewer this can cause the font to look awkward, better only print it one time.
It would also be better, if you would choose unique names for your coordinates instead of re-using d
for 3 of them. This has the big advantage, that you can easily control the order in which you draw things. For example you can first draw the grid in the background, then the axis, the dashed lines and the red dots at the end.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begingroup
scriptsize
begin{tikzpicture}[scale=0.7]
% grid
draw [thin, gray] (0,0) grid (5,5);
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$} |- (5,0) node (xaxis) [right] {$x$};
% Coordinates
coordinate (a) at (2,2);
coordinate (b) at (3,2);
coordinate (c) at (3,3);
coordinate (d) at (4,2);
% Dashed lines
draw[dashed] (yaxis |- a) node[left] {} -| (xaxis -| a) node[below] {$j-1$};
draw[dashed] (yaxis |- b) node[left] {} -| (xaxis -| b) node[below] {};
draw[dashed] (yaxis |- c) node[left] {$i+1$} -| (xaxis -| c) node[below] {$j$};
draw[dashed] (yaxis |- d) node[left] {$i$} -| (xaxis -| d) node[below] {$j+1$};
% red dots
fill[red] (a) circle (3pt);
fill[red] (b) circle (3pt);
fill[red] (c) circle (3pt);
fill[red] (d) circle (3pt);
end{tikzpicture}
endgroup
end{document}
add a comment |
If you don't mind that x and y will also become smaller, you could just use a smaller font size, e.g. by using scriptsize
before the tikzpicture
. This will also avoid the problem, that scaling elements that contain text will result in a suboptimal choice of letter shapes (see Why not scale elements that contain text for more information).
Another small problem: you print the labels for i
and j
three times above each other, depending on the rendering precision of your pdf viewer this can cause the font to look awkward, better only print it one time.
It would also be better, if you would choose unique names for your coordinates instead of re-using d
for 3 of them. This has the big advantage, that you can easily control the order in which you draw things. For example you can first draw the grid in the background, then the axis, the dashed lines and the red dots at the end.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begingroup
scriptsize
begin{tikzpicture}[scale=0.7]
% grid
draw [thin, gray] (0,0) grid (5,5);
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$} |- (5,0) node (xaxis) [right] {$x$};
% Coordinates
coordinate (a) at (2,2);
coordinate (b) at (3,2);
coordinate (c) at (3,3);
coordinate (d) at (4,2);
% Dashed lines
draw[dashed] (yaxis |- a) node[left] {} -| (xaxis -| a) node[below] {$j-1$};
draw[dashed] (yaxis |- b) node[left] {} -| (xaxis -| b) node[below] {};
draw[dashed] (yaxis |- c) node[left] {$i+1$} -| (xaxis -| c) node[below] {$j$};
draw[dashed] (yaxis |- d) node[left] {$i$} -| (xaxis -| d) node[below] {$j+1$};
% red dots
fill[red] (a) circle (3pt);
fill[red] (b) circle (3pt);
fill[red] (c) circle (3pt);
fill[red] (d) circle (3pt);
end{tikzpicture}
endgroup
end{document}
If you don't mind that x and y will also become smaller, you could just use a smaller font size, e.g. by using scriptsize
before the tikzpicture
. This will also avoid the problem, that scaling elements that contain text will result in a suboptimal choice of letter shapes (see Why not scale elements that contain text for more information).
Another small problem: you print the labels for i
and j
three times above each other, depending on the rendering precision of your pdf viewer this can cause the font to look awkward, better only print it one time.
It would also be better, if you would choose unique names for your coordinates instead of re-using d
for 3 of them. This has the big advantage, that you can easily control the order in which you draw things. For example you can first draw the grid in the background, then the axis, the dashed lines and the red dots at the end.
documentclass[a4paper, 12pt]{book}
usepackage{pgfplots, tikz}
begin{document}
begingroup
scriptsize
begin{tikzpicture}[scale=0.7]
% grid
draw [thin, gray] (0,0) grid (5,5);
% Draw axes
draw [<->,thick] (0,5) node (yaxis) [above] {$y$} |- (5,0) node (xaxis) [right] {$x$};
% Coordinates
coordinate (a) at (2,2);
coordinate (b) at (3,2);
coordinate (c) at (3,3);
coordinate (d) at (4,2);
% Dashed lines
draw[dashed] (yaxis |- a) node[left] {} -| (xaxis -| a) node[below] {$j-1$};
draw[dashed] (yaxis |- b) node[left] {} -| (xaxis -| b) node[below] {};
draw[dashed] (yaxis |- c) node[left] {$i+1$} -| (xaxis -| c) node[below] {$j$};
draw[dashed] (yaxis |- d) node[left] {$i$} -| (xaxis -| d) node[below] {$j+1$};
% red dots
fill[red] (a) circle (3pt);
fill[red] (b) circle (3pt);
fill[red] (c) circle (3pt);
fill[red] (d) circle (3pt);
end{tikzpicture}
endgroup
end{document}
edited 3 mins ago
answered 20 mins ago
samcarter
85.7k794275
85.7k794275
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468114%2fhow-to-scale-down-the-size-of-tick-on-an-axis-of-graph-in-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown