Tutorial. MAKE BETTER, PRETTIER BAR GRAPHS. [ Word Count: 700, ~ 3 PAGES | Revised: 2019.9.4 ]steemCreated with Sketch.

in #blog5 years ago

ffsdf.jpeg

 

 

BLOG

 

Today sharing:

Some code that I thought it worth sharing.

It draws what (I think) are pleasing bar graphs.

Just realized that most people here don't know you can whip out a bar graph to put somewhere without leaving the browser...

 

— 〈  1  〉—

HOW TO USE

 

To use you can install LaTeX. Or you can use Overleaf.com, for example, if you don't want to install anything; both will produce a pdf document.

Many people find using LaTeX difficult, but to grok it well, you merely need some better examples.

 

— 〈  2  〉—

CODE

 

% IF YOU DO NOT WANT TO INSTALL LaTeX AND USE IT TO COMPILE SUCH CODE YOU CAN MAKE A FEW CHANGES TO THIS CODE AS DESCRIBED BELOW AND USE OVERLEAF.COM TO COMPILE A FILE.PDF
\documentclass[12pt,letterpaper,onecolumn,openright]{article} % OR ELSE INSTEAD SET 
% OR ELSE INSTEAD SET \documentclass{standalone}
\usepackage{xcolor,pgfplots,tikz}
% AND THEN ALSO WRITE \pgfplotsset{compat=1.14}
% AND THEN ALSO WRITE \usepackage[english]{babel}\usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}

    \definecolor{b1}{HTML}{4F84BD}
    \definecolor{r1}{HTML}{C0504D}
    \definecolor{g1}{HTML}{8DBB79}
    \definecolor{p1}{HTML}{9F4C7C}

\begin{document}\begin{tikzpicture}
    \begin{axis}[
        width  = 1.2*\textwidth,
        height = 8cm,
        major x tick style = transparent,
        ybar=2*\pgflinewidth,
        bar width=14pt,
        ymajorgrids = true,
        ylabel = {\fontsize{8}{12}\selectfont P\,E\,R 100 S\,E\,T\,S (\,256 O\,B\,J\,E\,C\,T\,S)},
        symbolic x coords={Q\,U\,A\,N\,T\,I\,T\,Y,V\,A\,L\,U\,E\,(\,UNITS X\,),V\,A\,L\,U\,E\,(\,UNITS Y\,)},
        xtick = data,
        scaled y ticks = false,
        enlarge x limits=0.25,
        ymin=0,
        legend cell align=left,
        legend style={
                at={(1,1.05)},
                anchor=south east,
                column sep=1ex
        }
    ]
        \addplot[style={b1,fill=b1,mark=none}]
            coordinates {%
                (Q\,U\,A\,N\,T\,I\,T\,Y,343)
                (V\,A\,L\,U\,E\,(\,UNITS X\,),13.72)
                (V\,A\,L\,U\,E\,(\,UNITS Y\,),17.97)};

        \addplot[style={r1,fill=r1,mark=none}]
             coordinates {%
                (Q\,U\,A\,N\,T\,I\,T\,Y,124) 
                (V\,A\,L\,U\,E\,(\,UNITS X\,),27.28)
                (V\,A\,L\,U\,E\,(\,UNITS Y\,),37.73)
                         };

        \addplot[style={g1,fill=g1,mark=none}]
             coordinates {%
                (Q\,U\,A\,N\,T\,I\,T\,Y,28)
                (V\,A\,L\,U\,E\,(\,UNITS X\,),12.65)
                (V\,A\,L\,U\,E\,(\,UNITS Y\,),16.50)
                         };

        \addplot[style={p1,fill=p1,mark=none}]
             coordinates {%
                (Q\,U\,A\,N\,T\,I\,T\,Y,5)
                (V\,A\,L\,U\,E\,(\,UNITS X\,),50)
                (V\,A\,L\,U\,E\,(\,UNITS Y\,),65.5)
                         };

        \legend{%
            \textbf{Shorter}\,. . . . . . . .\hspace{1mm}0.04 UNITS,
            \textbf{Abcd}\,. . . . . . . . .\hspace{2mm}0.22 UNITS,
            \textbf{Efgh}\,. . . . . . . . .\hspace{3mm}0.45 UNITS,
            \textbf{Looonger}\,. . . . . .\hspace{2mm}10.0 UNITS%
               }
\end{axis}\end{tikzpicture}\end{document}

 

Pretty easy, what do you think?

ABOUT ME

I'm a scientist who writes science fiction under various names.

                         ◕ ‿‿ ◕ つ

    #writing   #creativity   #science   #fiction   #novel   #publishing   #blog
        @tribesteemup @thealliance @isleofwrite @freedomtribe @smg
            #technology   #cryptocurrency  #life  #history   #philosophy
                           #communicate   #freedom   #development   #future            

          UPVOTE !   FOLLOW !

 

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License Text and images: ©tibra. Disclaimer: This text is a popular, speculative discussion of basic science literature for the sake of discussion and regarding it no warranties of any kind exist. No promise to do anything or that anything is done is involved. Treat it all as mere conjecture about the past and the future. As subject to change. Else text is explicitly described as being fantasy or science fiction. If so, it is just that and then this is a work of fiction. Events, names, places, characters are either imagined or used fictitiously and any resemblance to real events or persons or places is coincidental.

Sort:  

Congratulations @tibra! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You distributed more than 35000 upvotes. Your next target is to reach 36000 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @tibra! You received a personal award!

Thank you for the witness votes you made to support your Steem community and for keeping the Steem blockchain decentralized

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Use your witness votes and get the Community Badge
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

To listen to the audio version of this article click on the play image.

Brought to you by @tts. If you find it useful please consider upvoting this reply.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.032
BTC 60046.04
ETH 2997.94
USDT 1.00
SBD 3.71