4

I am currently working on my summer project for which I created the following plot with Mathematica:

enter image description here

Now I am not 100% satisfied with the results and one of my professors recommended PGF and TikZ. The problem is I don't know anything about PGF and TikZ and I have to submit my project in 1.5 months.

So should I try to learn how to create beautiful plots with PGF and TikZ (i.e. is it possible to learn it in a week or so?) or should I just stick with my Mathematica plot? And are there even other alternatives?

edit:
As a few people have requested it, here is the Mathematica code:

max = 102000;
psi[x0_, y0_] := Module[{x = x0, y = y0, n = 2, c = 0}, 
  Do[If[Max[First[Transpose[FactorInteger[n]]]] <= y, c++]; n++;, {x}]; c]
data = Parallelize[Table[{n, psi[n, Ceiling[Sqrt[n]]]/n*100}, {n, 2, max, 1000}]];
p1 = Plot[{PrimePi[Sqrt[n]]/PrimePi[n]*100}, {n, 2, max}, PlotRange -> {{0, max}, {0, 55}},
   PlotStyle -> {Gray, Thick}, Epilog -> {Inset[Style["\[Pi](\!\(\*SqrtBox[\(n\)]\))/\[Pi](n)",
   FontSize -> 13, Bold], {40000, 7}], Inset[Style["\[Psi](n,\!\(\*SqrtBox[\(n\)]\))/n",
   FontSize -> 13, Bold], {max/2, 43}]}];
p2 = ListLinePlot[data, PlotRange -> {{0, max}, {0, 100}}, PlotStyle -> {Thick, Gray}];
p3 = Plot[{30}, {n, 2, max}, PlotRange -> {{0, max}, {0, 100}}, PlotStyle -> {Gray, Dashed}];
Show[p1, p2, p3, AxesLabel -> Table[Text[Style[{"n", "%"}[[i]], FontSize -> 13, Bold, Italic]],
   {i, 1, 2}], Ticks -> {Table[1/10*(max - 2000)*k, {k, 0, 9, 3}], Table[10 k, {k, 1, 10}]}]
Phil-ZXX
  • 1,747
  • 2
    I asked a similar question at http://tex.stackexchange.com/questions/116869/proper-tool-for-charts-in-tex. If you are reasonably comfortable with LaTeX you can learn enough pgfplots functionality in a week or so to do a 1.5 month project - particularly with help from this site - but I don't know whether TeX is powerful/convenient enough for the actual calculations you need. Those may call for mathematica, in which case the time invested in TeX may not pay off. – Ethan Bolker Jul 13 '13 at 16:22
  • The picture you've posted certainly is easy enough in pgfplots, with the proviso mentioned by @EthanBolker than you may have a little 'fun' with the calculations. gnuplot can help out with that, again depending on calculation complexity. – Joseph Wright Jul 13 '13 at 16:35
  • The question also is, does pgfplots allow me to use things like the prime-counting function pi and the counting function for smooth numbers phi? – Phil-ZXX Jul 13 '13 at 16:54
  • 5
    In my opinion the easiest thing to do is 1) elaborate the data you want to plot with some powerful program like Mathematica. 2) produce a file with the data and use pgfplots to plot it – Red Jul 13 '13 at 17:21
  • 2
    The mathematical functions available in pgfplots can not compete with Mathematica. That is not the point though, I export all complicated data to ascii files and use pgfplots to create the plots. Just try it out for an afternoon or so, it is not that complicated and the manual is great. – Alexander Jul 13 '13 at 17:21
  • The plots produced my Mathematica ar rather disappointing, especially for the recent version (>5). TikZ, with or without pgfplots is surely the best solution to provide nice looking graphs, but you can't make advanced calculations -- as you apparently need -- with it.

    An intermediate solution, if you don't want to invest the time and effort to learn, is to use gnuplot to plotdata exported from Mathematica.

    – Jhor Jul 13 '13 at 17:43
  • 1
    If you already have the data, one week is even too much. Edit your question and include some data (of 10-15 rows) otherwise this question is boring :P No seriously, just start with the manual it's quite straightforward but don't rush because it needs some initial care. As long as we can save another soul from matlab or mathematica (yes no capital letters, they can sue me) it would be great. – percusse Jul 13 '13 at 18:02
  • Depending on the other plots you need to make, Asymptote might better suit your needs. See http://tex.stackexchange.com/questions/39577/what-are-the-relative-strengths-of-tikz-and-asymptote for a comparison between TikZ and Asymptote and some discussion on plot making. – Emiel Jul 13 '13 at 18:10
  • And what about the Mathematica code? Why not to put it too? If it isn't too long, of course. – m0nhawk Jul 13 '13 at 18:27
  • 1
    @m0nhawk I edited my question. – Phil-ZXX Jul 13 '13 at 18:53
  • @Jhor: Your link points to an empty document at writeLaTeX... – krlmlr Jul 13 '13 at 20:08
  • 1
    Edited comment :
    You can have a Look at this example to have an idea about the plotting of tabulated data.
    – Jhor Jul 13 '13 at 20:46
  • @Jhor In my opinion that's not a good initial point for a beginner. – percusse Jul 14 '13 at 08:35
  • 1
    I hardly used Mathematica until now, I usually use Matlab. For Matlab, there is a nice script, called matlab2tikz https://github.com/nschloe/matlab2tikz which converts the data of a matlab plot into tikz. This actually works really good. Maybe there is something like that for Mathematica as well. – bene Jul 14 '13 at 08:57

0 Answers0