-
Notifications
You must be signed in to change notification settings - Fork 13
/
pyplot_majorminor.jl
52 lines (43 loc) · 1.5 KB
/
pyplot_majorminor.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# pyplot_majorminor.jl
#
# Demonstration of major and minor ticks
#
# gizmaa (https://gist.github.com/gizmaa/7214002)
# Julia 0.4.1
# 19.12.13
# Last Edit: 26.11.15
using PyPlot
###################
# Generate Data #
###################
x = [0.0:0.01:100.0;]
y = sin(0.1pi*x).*exp(-0.01x)
##########
# Plot #
##########
fig = figure("pyplot_majorminor",figsize=(10,10))
p = plot(x,y)
ax = gca()
xlabel("X Axis")
ylabel("Y Axis")
grid("on")
title("Major and Minor Ticks")
###########################
# Set the tick interval #
###########################
Mx = matplotlib[:ticker][:MultipleLocator](20) # Define interval of major ticks
f = matplotlib[:ticker][:FormatStrFormatter]("%1.2f") # Define format of tick labels
ax[:xaxis][:set_major_locator](Mx) # Set interval of major ticks
ax[:xaxis][:set_major_formatter](f) # Set format of tick labels
mx = matplotlib[:ticker][:MultipleLocator](5) # Define interval of minor ticks
ax[:xaxis][:set_minor_locator](mx) # Set interval of minor ticks
My = matplotlib[:ticker][:MultipleLocator](0.5) # Define interval of major ticks
ax[:yaxis][:set_major_locator](My) # Set interval of major ticks
my = matplotlib[:ticker][:MultipleLocator](0.1) # Define interval of minor ticks
ax[:yaxis][:set_minor_locator](my) # Set interval of minor ticks
#########################
# Set tick dimensions #
#########################
ax[:xaxis][:set_tick_params](which="major",length=10,width=2)
ax[:xaxis][:set_tick_params](which="minor",length=5,width=2)
fig[:canvas][:draw]() # Update the figure