Re: [julia-users] Plots with scale bars
Sure. You could maybe make a recipe, or just make a function that does this. You'll probably want to make use of 'axis_limits' to get the data range. Like this: amin, amax = axis_limits(plt[1][:yaxis]) Here 'plt[1]' returns the first Subplot. On Wednesday, August 10, 2016, Islam Badreldinwrote: > Hi Tom, > > Thanks for your input. This solution seems similar to the one proposed on > matlabcentral. It's fine for now, but it'd be great if switching between a > plot with x-y axes to a plot with only scale bars can be done neatly using > a single switch or function, while hiding all the details from the end > user. For example, figuring out the correct parameters for the text > annotation is a function of current plot scale (min/max), the text size of > the displayed text, ... etc. Ideally, the end user shouldn't need to fiddle > with all these details, and the scale bars functionality should `just work' > as the x-y axes functionality does! > > Thanks, > Islam > > PS: the first plot command gives me `ERROR: Unknown key: axis`. But I > assume that is because I'm currently on Julia v0.4.6 with Plots v0.8.2. > > On Wednesday, August 10, 2016 at 10:55:10 AM UTC-4, Tom Breloff wrote: > >> I threw this together really quickly... excuse the mess: >> >> using Plots >> >> # initial plot >> plot(linspace(10,34,100), 30rand(100,2).+[0 60], >> leg=false, ylim=(-60,150), axis=nothing, >> xguide="Time(ms)", yguide="current(mA)") >> >> # lines and annotations >> x,y = 12,-40 >> plot!([x,x,x+10], [y+10,y,y], c=:black, >>ann=[(x+5,y,text("10 ms",:top,10)), >> (x,y+5,text("10 mA",:right,10))]) >> >> png("/tmp/tmp") >> >> >> >> >> >> On Wed, Aug 10, 2016 at 10:31 AM, Willem Hekman >> wrote: >> >>> If you'd try to do this using PyPlot you can remove the x- and y-axis by >>> translating the necesarry matplotlib code i.e. >>> http://www.shocksolution.com/2011/08/removing-an-axis-or-bot >>> h-axes-from-a-matplotlib-plot/ >>> to the syntax that PyPlot takes, which is slightly different. You would >>> get something like >>> >>> plot(x,y) # some 2D plot call >>> ax = gca() # get current axes (the drawing area in PyPlot, dont confuse >>> axes with axis here) >>> ax[:get_xaxis][:set_visible](false) # make x-axis invisible >>> >>> for inspiration you can have a look at https://gist.github.com/gizmaa >>> /7214002 >>> >>> Adding the scale bars I cant seem to come up with a solution straight >>> away unfortunately, anyone has an idea? >>> >>> >>> On Monday, August 8, 2016 at 6:33:14 PM UTC+2, Islam Badreldin wrote: Hello, Is there a simple way in Julia to add scale bars with labels to plots and to hide the x-y axes as well? The way to do in MATLAB involves a lot of manual tweaking as described here http://www.mathworks.com/matlabcentral/answers/151248-add-a- scale-bar-to-my-plot I'm hoping to find a more elegant way in Julia! Thanks, Islam >>> >>
Re: [julia-users] Plots with scale bars
Yes likely this could be done easily in a recipe if it's something you'd want to do repeatedly. On Monday, August 8, 2016, Islam Badreldin <islam.badrel...@gmail.com> wrote: > > Hi Tom, > > It'd be cool if you can add a couple of examples, yes! > > I'm not familiar with plot recipes yet, but do you think that such a > scenario can be handled 'neatly' in a recipe while hiding all manual > tweaking from the end user? > > Thanks, > Islam > > _ > From: Tom Breloff <t...@breloff.com > <javascript:_e(%7B%7D,'cvml','t...@breloff.com');>> > Sent: Monday, August 8, 2016 1:03 PM > Subject: Re: [julia-users] Plots with scale bars > To: <julia-users@googlegroups.com > <javascript:_e(%7B%7D,'cvml','julia-users@googlegroups.com');>> > > > There's a bunchof ways to do this with Plots. Draw the lines and add > annotations or add an inset subplot with labels? I'm not at a computer... > maybe I'll throw together an example later. > > On Monday, August 8, 2016, Islam Badreldin <islam.badrel...@gmail.com > <javascript:_e(%7B%7D,'cvml','islam.badrel...@gmail.com');>> wrote: > >> >> >> Hello, >> >> Is there a simple way in Julia to add scale bars with labels to plots and >> to hide the x-y axes as well? The way to do in MATLAB involves a lot of >> manual tweaking as described here >> http://www.mathworks.com/matlabcentral/answers/151248-add-a- >> scale-bar-to-my-plot >> >> I'm hoping to find a more elegant way in Julia! >> >> Thanks, >> Islam >> > > >
Re: [julia-users] Plots with scale bars
Hi Tom, It'd be cool if you can add a couple of examples, yes! I'm not familiar with plot recipes yet, but do you think that such a scenario can be handled 'neatly' in a recipe while hiding all manual tweaking from the end user? Thanks,Islam _ From: Tom Breloff <t...@breloff.com> Sent: Monday, August 8, 2016 1:03 PM Subject: Re: [julia-users] Plots with scale bars To: <julia-users@googlegroups.com> There's a bunchof ways to do this with Plots. Draw the lines and add annotations or add an inset subplot with labels? I'm not at a computer... maybe I'll throw together an example later. On Monday, August 8, 2016, Islam Badreldin <islam.badrel...@gmail.com> wrote: Hello, Is there a simple way in Julia to add scale bars with labels to plots and to hide the x-y axes as well? The way to do in MATLAB involves a lot of manual tweaking as described herehttp://www.mathworks.com/matlabcentral/answers/151248-add-a-scale-bar-to-my-plot I'm hoping to find a more elegant way in Julia! Thanks,Islam
Re: [julia-users] Plots with scale bars
There's a bunchof ways to do this with Plots. Draw the lines and add annotations or add an inset subplot with labels? I'm not at a computer... maybe I'll throw together an example later. On Monday, August 8, 2016, Islam Badreldinwrote: > > > Hello, > > Is there a simple way in Julia to add scale bars with labels to plots and > to hide the x-y axes as well? The way to do in MATLAB involves a lot of > manual tweaking as described here > http://www.mathworks.com/matlabcentral/answers/151248- > add-a-scale-bar-to-my-plot > > I'm hoping to find a more elegant way in Julia! > > Thanks, > Islam >
[julia-users] Plots with scale bars
Hello, Is there a simple way in Julia to add scale bars with labels to plots and to hide the x-y axes as well? The way to do in MATLAB involves a lot of manual tweaking as described here http://www.mathworks.com/matlabcentral/answers/151248-add-a-scale-bar-to-my-plot I'm hoping to find a more elegant way in Julia! Thanks, Islam