Используйте таблица ASCII для выбора диапазона букв, где: $range_start, $range_end является значением из десятичного столбца в таблице ASCII.
я нахожу, что этот метод более хорош сравненный к методу, описал , где диапазон символов конкретно определяется в другой строке.
// range is numbers (48) through capital and lower case letters (122)
$range_start = 48;
$range_end = 122;
$random_string = "";
$random_string_length = 10;
for ($i = 0; $i < $random_string_length; $i++) {
$ascii_no = round( mt_rand( $range_start , $range_end ) ); // generates a number within the range
// finds the character represented by $ascii_no and adds it to the random string
// study **chr** function for a better understanding
$random_string .= chr( $ascii_no );
}
echo $random_string;
Посмотрите Больше:
Here you want to use the Artist objects, and pass them as needed to the functions:
import numpy as np
import matplotlib.pyplot as plt
def myhist(ax, color):
ax.hist(np.log(np.arange(1, 10, .1)), facecolor=color)
def say_something(ax, words):
t = ax.text(.2, 20., words)
make_a_dim_yellow_bbox(t)
def make_a_dim_yellow_bbox(txt):
txt.set_bbox(dict(facecolor='yellow', alpha=.2))
fig = plt.figure()
ax0 = fig.add_subplot(1,2,1)
ax1 = fig.add_subplot(1,2,2)
myhist(ax0, 'blue')
myhist(ax1, 'green')
say_something(ax0, 'this is the blue plot')
say_something(ax1, 'this is the green plot')
plt.show()
Okey, I've figured out how to do this. It was a lot simpler than what I had imagined. It just required a bit of reading here with the figure and axes classes.
In your main script:
import pylab as plt
import DrawFns
fig = plt.figure()
(do something with fig)
DrawFns.WriteText(fig, 'Testing')
plt.show()
In your DrawFns.py:
def WriteText(_fig, _text):
[indent]_fig.text(0, 0, _text)
And that's it! And I can add more functions in DrawFns.py and call them from any script as long as they are included with import
call. :D