Graphics, Figures & Tablespgfplots | Alter Grid Frequency

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Hrs
Posts: 16
Joined: Sat May 12, 2012 3:13 pm

pgfplots | Alter Grid Frequency

Post by Hrs »

Hi all!

By executing my code (see below), I have a plot with grid, but I need grid to be frequently than now. How should I change it?

Thank you in advance!

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel = {f, кГц.}, ylabel = K., grid=both]
\addplot[mark = none] coordinates {
(1.0,0.2647154501503825)
(1.5,0.3807477796923222)
(2.0,0.4812565113579688)
(2.5,0.565840103506494)
(3.0,0.635704895972674)
(3.5,0.6928238526553094)
(4.0,0.739340295895993)
(4.5,0.7772429561896744)
(5.0,0.8082347524695772)
(5.5,0.8337107197436225)
(6.0,0.8547860827588784)
(6.5,0.8723412026433603)
(7.0,0.8870673772786325)
(7.5,0.899507090248347)
(8.0,0.9100870187934802)
(8.5,0.9191441426044205)
(9.0,0.9269460013441607)
(9.5,0.9337062611352089)
(10.0,0.9395966305202977)
(10.5,0.9447559803887224)
(11.0,0.9492973390961651)
(11.5,0.9533132775786582)
(12.0,0.9568800742737721)
(12.5,0.9600609532007208)
(13.0,0.9629086155052814)
(13.5,0.9654672300178736)
(14.0,0.9677740075186188)
(14.5,0.9698604529611057)
(15.0,0.97175336720142)
(15.5,0.973475652802669)
(16.0,0.9750469657481947)
(16.5,0.9764842453006364)
(17.0,0.9778021469811882)
(17.5,0.9790133981197677)
(18.0,0.9801290912047418)
(18.5,0.9811589270172225)
(19.0,0.9821114170302495)
(19.5,0.9829940526092366)
(20.0,0.9838134470337896)
};
\end{axis}
\end{tikzpicture}
\end{document}
Last edited by localghost on Mon Nov 05, 2012 6:33 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

pgfplots | Alter Grid Frequency

Post by localghost »

Since you do not describe properly how you want the grid, I can only refer you to the pgfplots manual. It describes the options xtick and ytick for the axis environment.


Thorsten
Hrs
Posts: 16
Joined: Sat May 12, 2012 3:13 pm

pgfplots | Alter Grid Frequency

Post by Hrs »

how you want the grid
I want it to be 10 times frequently than now.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

pgfplots | Alter Grid Frequency

Post by localghost »

Hrs wrote:I want it to be 10 times frequently than now.
I'm afraid I can't follow you. What does that mean? More ticks with less distance in between or what? If you set more ticks, the plot might become unclear.
Hrs
Posts: 16
Joined: Sat May 12, 2012 3:13 pm

pgfplots | Alter Grid Frequency

Post by Hrs »

More ticks with less distance in between
Yes.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: pgfplots | Alter Grid Frequency

Post by svend_tveskaeg »

I guess Hrs means "I would like the lines to occur 10 times as frequent, i.e., with 1/10 the current distance between them" instead of "I want it to be 10 times frequently than now". ;)
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

pgfplots | Alter Grid Frequency

Post by localghost »

OK then. Let's summarize. The grid that is automatically produced by the provided code has several properties.
  • On the x axis values go from 0 to 20 with ticks in steps of 5 (→ 4 ticks)
  • On the y axis values go from 0.2 to 1 with ticks in steps of 0.2 (→ 4 ticks)
The desired grid shall have ten times more ticks on the axes as the original. So this is what we get.
  • On the x axis values go from 0 to 20 with ticks in steps of 0.5 (→ 40 ticks)
  • On the y axis values go from 0.2 to 1 with ticks in steps of 0.02 (→ 40 ticks)
Hence the axis environment only needs some more options as I already mentioned in my first reply. But this is going to be weird (see attachment).

Code: Select all

\begin{axis}[
  xmin=0,
  xmax=20,
  xlabel={x axis},
  xtick={0,0.5,...,20},
  ymin=0.2,
  ymax=1,
  ylabel={y axis},
  ytick={0.2,0.22,...,1},
  grid=both
]
  % plot content
\end{axis}
And I don't think that you really want this output. I strongly recommend to read the respective manuals for information about possible customization. All other questions will be answered by just a bit of reading.


Further reading:
Attachments
utmp.png
utmp.png (17.42 KiB) Viewed 8923 times
Hrs
Posts: 16
Joined: Sat May 12, 2012 3:13 pm

Re: pgfplots | Alter Grid Frequency

Post by Hrs »

Yes, I don't need numbering be 10 times frequently... only grid. Maybe i should try to combine 2 different pairs of axis, to do what i want...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

pgfplots | Alter Grid Frequency

Post by localghost »

Hrs wrote:[…] Maybe i should try to combine 2 different pairs of axis, to do what i want...
No need for that. Just search the pgfplots manual for the minor tick num option and give it to the axis environment.
Post Reply