Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
eicplot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
EIC
eicplot
Commits
1ec75e1f
Commit
1ec75e1f
authored
Mar 08, 2018
by
David Blyth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved things into axis.go
parent
c47e5b52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
axis.go
axis.go
+34
-0
No files found.
tick
s.go
→
axi
s.go
View file @
1ec75e1f
...
...
@@ -7,6 +7,20 @@ import (
"gonum.org/v1/plot"
)
type
LogScale
struct
{}
func
(
LogScale
)
Normalize
(
min
,
max
,
x
float64
)
float64
{
logMin
:=
log10
(
min
)
return
(
log10
(
x
)
-
logMin
)
/
(
log10
(
max
)
-
logMin
)
}
func
log10
(
x
float64
)
float64
{
if
x
<=
0
{
return
-
1
}
return
math
.
Log10
(
x
)
}
type
PreciseTicks
struct
{
NSuggestedTicks
int
}
...
...
@@ -103,6 +117,26 @@ func round(x float64, prec int) float64 {
return
x
/
pow
}
type
LogTicks
struct
{}
func
(
LogTicks
)
Ticks
(
min
,
max
float64
)
[]
plot
.
Tick
{
val
:=
math
.
Pow10
(
int
(
log10
(
min
)))
max
=
math
.
Pow10
(
int
(
math
.
Ceil
(
log10
(
max
))))
var
ticks
[]
plot
.
Tick
for
val
<
max
{
for
i
:=
1
;
i
<
10
;
i
++
{
if
i
==
1
{
ticks
=
append
(
ticks
,
plot
.
Tick
{
Value
:
val
,
Label
:
formatFloatTick
(
val
,
-
1
)})
}
ticks
=
append
(
ticks
,
plot
.
Tick
{
Value
:
val
*
float64
(
i
)})
}
val
*=
10
}
ticks
=
append
(
ticks
,
plot
.
Tick
{
Value
:
val
,
Label
:
formatFloatTick
(
val
,
-
1
)})
return
ticks
}
func
formatFloatTick
(
v
float64
,
prec
int
)
string
{
return
strconv
.
FormatFloat
(
v
,
'g'
,
prec
,
64
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment