Plots with Plots

376 views
Skip to first unread message

Tom Breloff

unread,
Jun 24, 2016, 11:37:15 AM6/24/16
to julia-users
I just uploaded the IJulia notebook which was my JuliaCon workshop: https://github.com/tbreloff/ExamplePlots.jl/blob/master/notebooks/plotswithplots.ipynb.

You'll need to be on master or dev to follow along until I tag 0.7.3.  The documentation is getting more and more complete, so I recommend giving it a quick read if you're curious about Plots: http://plots.readthedocs.io/en/latest/

-Tom

jw3126

unread,
Jun 24, 2016, 12:20:08 PM6/24/16
to julia-users
Looks pretty awesome!

daycaster

unread,
Jun 25, 2016, 9:19:38 AM6/25/16
to julia-users
Plots.jl looks amazing!

A couple of questions:
Is there any way to control the fonts used in a plot? I can't see any obvious way to specify fonts outside the usual range of "Helvetica"/"Courier".

Also, I can't get any results from searching the docs. Is search currently broken or are there ways to specify words that I don't know?

Tom Breloff

unread,
Jun 27, 2016, 2:31:33 PM6/27/16
to julia-users
For anyone interested, I made a short demo of what's possible with the GLVisualize backend in Plots, after hacking at JuliaCon with Simon.  Plots, Interact, and GLVisualize... oh my!


I just tagged a new version of Plots... until it's merged you'll need to be on master or dev.  We're not quite ready for bug reports on GLVisualize... plenty of things on Simon's todo list :D

Henri Girard

unread,
Jun 28, 2016, 3:23:06 AM6/28/16
to julia-users
That's what I get,any help  :
Pkg.checkout("Plots")
Pkg.checkout("PlotRecipes")


using Plots, PlotRecipes
pyplot()
import Plots: _apply_recipe, KW
immutable F
f::Function
end
getf(f::F) = f.f
--------------------
WARNING: could not import Plots._apply_recipe into Main
-----------------------
_apply_recipe(d::KW, f::F, args...; kw...) = (f.f, args...)
plot(F(sin), 0, 4π)
-------------------
[Plots.jl] Initializing backend: pyplot
LoadError: In convertToAnyVector, could not handle the argument types: (F,)
while loading In[6], in expression starting on line 3

 [inlined code] from /home/pi/.julia/v0.4/Plots/src/series_new.jl:86
 in apply_recipe at /home/pi/.julia/v0.4/RecipesBase/src/RecipesBase.jl:235
 in _plot! at /home/pi/.julia/v0.4/Plots/src/plot.jl:312
 in plot at /home/pi/.julia/v0.4/Plots/src/plot.jl:52


Tom Breloff

unread,
Jun 28, 2016, 8:08:50 AM6/28/16
to julia...@googlegroups.com
I think you must be looking at an old example? Can you tell me where you found it so I can update? '_apply_recipe' doesn't exist, and you shouldn't have to import it anyways. 

Let me know what your end goal is and I can help. I understand the docs need better organization. 

Henri Girard

unread,
Jun 28, 2016, 8:26:19 AM6/28/16
to julia-users
Well... It's here I got your examples :
https://github.com/tbreloff/ExamplePlots.jl/blob/master/notebooks/apply_recipe.ipynb
I just wanted to try it...
My next aim is to use ODE with plots to do my portrait phase and RLC from pyplot to Plots --------------------------------------pyplot---------

w0=1/sqrt(L*C)
Q=sqrt(L/C)/R
tau=2*Q/w0
E=6;
function rlc(y,t)
    return([y[2],-w0^2*y[1]-(w0/Q)*y[2]])
end;
y0=[E,0];
listet=linspace(0,5*tau,1000)
liste_u_uprime=integrate.odeint(rlc,y0,listet)
listeu=liste_u_uprime[:,1]
listeuprime=liste_u_uprime[:,2];
plt.clf()
plt.plot(listet,listeu,label="U(t)")
plt.title("RLC")
plt.xlabel("t (s)")
plt.ylabel("U(v)")
plt.grid()
plt.legend(loc=4);
--------------------------------------
plt.clf()
plt.plot(listeu,listeuprime,label="U\'=fct(U)")
plt.xlabel("U (V)")
plt.ylabel("U' (V/s)")
plt.title("Portrait de phase  RLC regime libre")
plt.grid()
plt.legend(loc=4);
-------------------------------------
this with ODE in Plots
I thaught it would be easy but I was wrong !
Plots has nicer environment than pyplot (I like your dark one with black background I can't make it with pyplot

Tom Breloff

unread,
Jun 28, 2016, 9:12:47 AM6/28/16
to julia...@googlegroups.com
Ok I don't think you need recipes for this... just a simple call to 'plot' with the attributes you want. See the "attributes" page of the docs for descriptions of what's available. 


On Tuesday, June 28, 2016, Henri Girard <henri....@gmail.com> wrote:

Henri Girard

unread,
Jun 28, 2016, 9:43:21 AM6/28/16
to julia-users
Thanks, I am doing yin-yang but have problems to color,
I want it red and grey :
using Plots
function h(x)
    if x<0
        return sqrt(-x^2-2*x)
    else
        return -sqrt(-x^2+2*x)
    end
end;
x=linspace(-2,2)
t=linspace(-pi/3,pi/3)
f(x) = sqrt(4-x^2)
g(x) = -sqrt(4-x^2);
d=plot(h, -2,2,aspect_ratio=1)
a=plot(h,fill=g, -2,2,aspect_ratio=1)
b=plot(h,fill=f, -2,2,aspect_ratio=1)
plot([h,g,f], -2,2,aspect_ratio=1)

Le vendredi 24 juin 2016 17:37:15 UTC+2, Tom Breloff a écrit :
Reply all
Reply to author
Forward
0 new messages