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 <[email protected] 
> <javascript:>> 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-both-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
>>>
>>
>

Reply via email to