Graphics, Figures & TablesAdjust the graphs

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Reza7Emarloo
Posts: 2
Joined: Fri Feb 19, 2021 7:28 am

Adjust the graphs

Post by Reza7Emarloo »

I'v been using the pstricks package for drawing my graph.The axis not only runs past the right and left side of the graph, but I can't fixed it. I want this shape to fit the page (left=3.5cm, right=3.5cm).I just want it to be small and come in the middle and be at the top of the page. I have to say the shape is drawn correctly, but only slightly larger!
Can you help a little more?

Code: Select all

%!TEX xelatex
\documentclass[12pt]{article}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\usepackage{pgfplots}
\usepackage{pstricks,pst-plot}
\begin{document}
\begin{figure}[htb]
\begin{centering}
\begin{pspicture}	
\psaxes[ticks=none,xunit=.5cm]  (0,0)(0,10)(30,0)
\psdots[dotstyle=Oplus,dotsize=10pt] (1,1)(2,2)(-1,3)(-3,5)
\psline {->}(1,1)(13,1)
\psline(15,0)(15,10)
\psline {->}(2,2)(16,2)
\psline{->}(-1,3)(8,3)
\psline{->}(-3,5)(17,5)
\end{pspicture}
\end{centering}
\caption{censoring observed}
\end{figure}
\end{document}
Attachments
s2.PNG
s2.PNG (25.27 KiB) Viewed 1736 times
Last edited by Stefan Kottwitz on Thu Mar 11, 2021 1:52 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

Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Adjust the graphs

Post by Ijon Tichy »

With
\psaxes[ticks=none,xunit=.5cm] (0,0)(0,10)(30,0)
you draw an x-axes from 0 up to 30*xunit=15, but with
\psline{->}(-3,5)(17,5)
you draw a line from (-3,5) to (17,5). So it should be expected, that the line starts -3=-6*xunit from the left of the x-axes and 2=4*xunit right from it.

Unfortunately I do not know, what you've expected. So I cannot give you a solution. But IMHO you either have to change the values of \psaxes or of the \psline commands.

BTW: \centering is a command, that works as a switch. You should not use it as an environment, but simple \begin{figure}\centering…\end{figure}. And after loading pgfplots you should always explicitly set option compat. See the manual for more information.

Alternatively you could use TikZ and pgfplots, which you are already loading (and do not need for a real Infominimal working example).

And please always mark code in postings. You can either select the code with the mouse and then click to the Code button in the toolbar or add the proper Tags around the code.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply