I'm going to draw a certain function from a .txt file. I'd like to specify/to highlight a point of that function on the function itself by a marker and a label.

Moreover, I'd like to put a notch on the x-axis and a label.

Can you suggest the code needed to carry it out?

Thank you!!!

What is following is the code I wrote.

\documentclass[a4paper, landscape, 8pt]{book}


\usepackage{tikz, siunitx, pgfplots, relsize, pgfmath}
\usetikzlibrary{intersections, pgfplots.units}



\pgfplotsset{change x base,
            x SI prefix=milli,
            change y base,
            y SI prefix=micro

every axis/.append style = {
% riguarda le tick labels
line width = 1pt,
% oppure: thin, semithick, thick,
% very thick
tick style = {line width = 1pt}
every axis x label/.append style = {
font = \relsize{2}
every axis y label/.append style = {
font = \relsize{2},
rotate = -90
%xshift = -0.7em,
%yshift = -1.4em
major grid style = {
line width = 0.5pt,
%dash pattern = on 4pt off 4pt
every axis title/.append style = {
font = \relsize{1}
legend style={at={(850e-3, 700e-3)},anchor=north, line width=1pt}

    [   axis background/.style={fill=gray!15},
        %axis x line=bottom,
        %axis y line=left,
        xmin=-0.3, xmax=0.3,
        ymin=-0.000004, ymax=0.000004,
        x unit=V,
        %x unit prefix=m,
        y unit=A,
        %y unit prefix=u,
        minor x tick num = 1,
        minor y tick num = 1,
        width=12cm, height=9cm,
        %xtick = {-0.3,-0.2,...,0.3},
        %ytick = {-0.000004,-0.000003,...,0.000004},
        xlabel = {$V_d$},
\addplot [thick, green!100] file {diffecorrenti.txt};


  • Please add to your question a simple test file diffecorrenti.txt so your example becomes quickly compilable for everyone. Dec 14, 2014 at 17:02
  • I'm sorry. The file could not be easy to handle because of the fact that it is very "heavy". I'll try to post two photos so that everyone can understand the problem.
    – leoleoleo
    Dec 14, 2014 at 17:08
  • @leoleoleo: Instead of posting pictures, it would be much better if you could reduce the code to make it self-contained: Remove all the lines that don't have anything to do with your question (\usepackage{etex}, for example, or font=\relsize{1} and so on) and include some dummy data.
    – Jake
    Dec 14, 2014 at 17:18
  • The problem is very similar to this one: tex.stackexchange.com/questions/129571/…..... BUT I have got a txt and not a math function. THANKS a lot.
    – leoleoleo
    Dec 14, 2014 at 17:30
  • @leoleoleo Then make a much shorter data file and post that in the example. Beyond that, how do you want the point selected: "highlight the point nearest (or at) x=k", "highlight the k-th point", ...? Dec 14, 2014 at 18:16

1 Answer 1


One possibility; for this example I used the following simple file diffecorrenti.txt:

1 2
3 -3
4 5
6 7

and suppressed parts of the original code that were not relevant to the question and to the solution.

enter image description here

  1. For the first requirement, you can use the axis cs coordinate system to place a \node with some predefined style at the desired location at one point in your graph. In the example I did this in two ways:

    • Using a simple \node in the shape of a filled circle and used the label key to place the label.
    • Using a \node and a pin to add the label.
  2. For the second requirement, you can use the extra x ticks (and perhaps also extra x tick labels) to add additional tick positions and tick labels to the x axis.

The code:



every pin/.style={
small dot/.style={


   axis background/.style={fill=gray!15},
  minor x tick num = 1,
  minor y tick num = 1,
  xlabel = {$V_d$},
  extra x ticks={1.2,4.7},
  extra x tick labels={extra1,extra2},
  extra x tick style={
    tick label style={rotate=90}
\addplot [thick, green] file {diffecorrenti.txt};
\node[small dot,label=left:{$(4,5)$}] at (axis cs:4,5) {};
\node[small dot,pin=30:{$(3,-3)$}] at (axis cs:3,-3) {};

  • Thank you very much! I'll try your solution. The second requirement could be ok... For the first one I have some doubts because You've supposed to know the exactly position of that points. For example, (4,5) is on your list. In my case, the coordinates of the point, could not be on the list. (They could be situated between two consecutives other points. What do you think about this? Could it be a problem? Thank you again!
    – leoleoleo
    Dec 17, 2014 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .