Как я могу заставить изображения pyplot показывать на консольном приложении?

Хорошо, вот F#, пытаясь остаться читаемым, на уровне приблизительно 830 байтов:

#light
let thou=[|"";"thousand";"million";"billion";"trillion";"quadrillion";"quintillion"|]
let ones=[|"";"one";"two";"three";"four";"five";"six";"seven";"eight";"nine";"ten";"eleven";
  "twelve";"thirteen";"fourteen";"fifteen";"sixteen";"seventeen";"eighteen";"nineteen"|]
let tens=[|"";"";"twenty";"thirty";"forty";"fifty";"sixty";"seventy";"eighty";"ninety"|]
let (^-) x y = if y="" then x else x^"-"^y
let (^+) x y = if y="" then x else x^" "^y
let (^?) x y = if x="" then x else x^+y
let (+^+) x y = if x="" then y else x^+y
let Tiny n = if n < 20 then ones.[n] else tens.[n/10] ^- ones.[n%10]
let Small n = (ones.[n/100] ^? "hundred") +^+ Tiny(n%100)
let rec Big n t = if n = 0UL then "" else
  (Big (n/1000UL) (t+1)) +^+ (Small(n%1000UL|>int) ^? thou.[t])
let Convert n = if n = 0UL then "zero" else Big n 0

и вот модульные тесты

let Show n = 
    printfn "%20u -> \"%s\"" n (Convert n)

let tinyTests = [0; 1; 10; 11; 19; 20; 21; 30; 99] |> List.map uint64
let smallTests = tinyTests @ (tinyTests |> List.map (fun n -> n + 200UL))
let MakeTests t1 t2 = 
    List.map (fun n -> n * (pown 1000UL t1)) smallTests
    |> List.map_concat (fun n -> List.map (fun x -> x * (pown 1000UL t2) + n) smallTests)
for n in smallTests do
    Show n
for n in MakeTests 1 0 do
    Show n
for n in MakeTests 5 2 do
    Show n            
Show 1000001000678000001UL
Show 17999999999999999999UL
11
задан Nathan Fellman 3 November 2009 в 22:14
поделиться

2 ответа

You have to call the show function to actually display anything, like

matplotlib.pyplot.show()

Unfortunately the matplotlib documentation seems to be currently broken, so I can't provide a link.

Note that for interactive plotting one typically uses IPython, which has special support for matplotlib.

By the way, you can do

import matplotlib.pyplot as plt

to make the typing less tedious (this is pretty much the official standard way).

10
ответ дан 3 December 2019 в 10:04
поделиться
0
ответ дан 3 December 2019 в 10:04
поделиться
Другие вопросы по тегам:

Похожие вопросы: