Graphics, Figures & TablesLittle problems with PGFplots package

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
azoun
Posts: 3
Joined: Wed Dec 02, 2009 1:47 am

Little problems with PGFplots package

Post by azoun »

Hi,

i'm new. I use MikTEX 2.8 and Led editor.

Many thanks to all topics, i found them very usefull soooo many times.

Here it is the question:
After writing all i need in the preamble i type this code

Code: Select all

\begin{figure}[H] 
\centering 

%GRAPH OPTIONS 
\pgfplotsset{ 
legend style = {font=,
                  at={(2.5cm,6.5cm)}}, 
grid         = major, 
axis x line  = bottom,
axis y line  = left, 
width        = 0.8\textwidth,
height       = 0.8\textwidth, 
xlabel       = $x$,
ylabel       = $y$} 

%GRAPH
\begin{tikzpicture} 
\begin{axis} 
\addplot[blue]  expression[domain=0:6] {2*x^2}; 
\addlegendentry{$i=2$} 
\addplot[red]   expression[domain=0:6] {2.5*x^2.5}; 
\addlegendentry{$i=2.5$} 
\addplot[green] expression[domain=0:6] {3*x^3}; 
\addlegendentry{$i=3$} 
\end{axis} 
\end{tikzpicture} 

\caption{Grafico della funzione $y=i\cdotp x^i$} 
\end{figure} 
and i obtain a graph where the figure is centered but not the x-coordinates.

How can i solve it?

Thanks in advance.
Last edited by azoun on Thu Dec 10, 2009 11:27 am, edited 1 time 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.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Little problems with PGFplots package

Post by gmedina »

Hi,

please post a complete, compilable and minimal version of the problematic code.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
azoun
Posts: 3
Joined: Wed Dec 02, 2009 1:47 am

Little problems with PGFplots package

Post by azoun »

sorry.

here is the minimal compilable code

Code: Select all

\documentclass[11pt,oneside,a4paper]{report}

\usepackage[italian]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[]{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{subfigure}
\usepackage{float}
\usepackage[bf,hang]{caption}
\captionsetup{labelsep=space}

\begin{document}

\begin{figure}[H] 
\centering 

%GRAPH OPTIONS 
\pgfplotsset{ 
legend style            = {font=,
                             at={(2.5cm,6.5cm)}}, 
grid                    = major, 
axis x line             = bottom,
axis y line             = left, 
width                   = 0.8\textwidth,
height                  = 0.8\textwidth, 
xlabel                  = $x$,
ylabel                  = $y$, 
legend style            = {cells={anchor=west}},% <-- this is new
ylabel style            = {overlay},            % <-- this is new
yticklabel style        = {overlay}             % <-- this is new
}%

%GRAPH
\begin{tikzpicture} 
\begin{axis} 
\addplot[blue]  expression[domain=0:6] {2*x^2}; 
\addlegendentry{$i=2$} 
\addplot[red]   expression[domain=0:6] {2.5*x^2.5}; 
\addlegendentry{$i=2.5$} 
\addplot[green] expression[domain=0:6] {3*x^3}; 
\addlegendentry{$i=3$} 
\end{axis} 
\end{tikzpicture} 

\caption{Grafico della funzione $y=i\cdotp x^i$} 
\end{figure} 
\end{document}
Is it possible to center the x axis?

UPDATE

yes it is possible. look the new rows on the code (labeled <- this is new)
Post Reply