绝望和matplotlib?
Kivy and matplotlib?
我只是想知道 matplotlib 是否与 kivy 1.9.0 兼容,如果可能的话我该如何实现它?如果不支持,kivy有没有类似的东西?
我希望能够在我的 kivy 应用程序中使用我的程序中的这个特定代码:
def printPieChart(table, column):
if column == 6:
columnList = table.iloc[:, -1:].values.T.ravel()
else:
columnList = table.iloc[:, (column - 7): (column - 6)].values.T.ravel()
countedList = Counter(columnList)
#set up the size of the pie chart
fig = plt.figure(figsize=[10, 10])
ax = fig.add_subplot(111)
cmap = plt.cm.prism
#input variables for pie function
slices = [float(v) for v in countedList.values()]
colors = cmap(np.linspace(0., 1., len(slices)))
labels = [float(k) for k in countedList]
columnHeaders = list(table.columns.values)
#the pie chart
pie_wedge_collection = ax.pie(slices, colors = colors, labels = labels, labeldistance = 1.05, autopct = '%1.1f%%')
#get rid of the black outlines between the wedges and around the pie
for pie_wedge in pie_wedge_collection[0]:
pie_wedge.set_edgecolor('white')
ax.set_title(columnHeaders[column + 1])
如果我想为 matplotlib 做一个编译方法,会不会是这样?
#!/bin/bash
VERSION_matplotlib=${VERSION_matplotlib:-1.4.3}
DEPS_matplotlib=(numpy python dateutil pyparsing six linpng pytz freetype agg PyCXX qhull ttconv)
URL_matplotlib=http://pypi.python.org/packages/source/m/matplotlib/matplotlib-$VERSION_matplotlib.tar.gz
MD5_matplotlib=f43c20480a1673185afefc7d4848a1d2
BUILD_matplotlib=$BUILD_PATH/matplotlib/$(get_directory $URL_matplotlib)
RECIPE_matplotlib=$RECIPES_PATH/matplotlib
# function called for preparing source code if needed
# (you can apply patch etc here.)
function prebuild_matplotlib() {
true
}
function shouldbuild_lxml() {
if [ -d "$SITEPACKAGES_PATH/matplotlib" ]; then
DO_BUILD=0
fi
}
# function called to build the source code
function build_matplotlib() {
cd $BUILD_matplotlib
push_arm
export CC="$CC -I$BUILD_numpy/"
export LDFLAGS="-L$BUILD_numpy/numpy/.libs -L$BUILD_numpy/numpy/.libs -L$BUILD_numpy/.libs -L$BUILD_numpy/numpy -L$BUILD_numpy/numpy -L$BUILD_numpy/ $LDFLAGS"
export LDSHARED="$LIBLINK"
chmod +x $BUILD_numpy/numpy-config
export PATH=$PATH:$BUILD_numpy
#plus more for the other dependencies
try $HOSTPYTHON setup.py build_ext -I$BUILD_matplotlib
try find . -iname '*.pyx' -exec $CYTHON {} \;
try $HOSTPYTHON setup.py build_ext -v
try find build/lib.* -name "*.o" -exec $STRIP {} \;
export PYTHONPATH=$BUILD_hostpython/Lib/site-packages
try $BUILD_hostpython/hostpython setup.py install -O2 --root=$BUILD_PATH/python-install --install-lib=lib/python2.7/site-packages
unset LDSHARED
pop_arm
}
# function called after all the compile have been done
function postbuild_matplotlib() {
true
}
你可以从 kivy 脚本中调用 matplotlib,就像你通常那样,但是 kivy 没有内置的方式来显示绘图 - 你必须让 matplotlib 来渲染它们(例如,作为 png,或者你可以尝试 kivy 的实验性 svg 支持,但它可能有问题)然后将它们显示在图像小部件或类似的小部件中。
如果您想在 android 或 ios 上执行此操作,您需要 matplotlib 的编译方法,因为我认为我们还没有。我认为这应该不会太难,如果您有兴趣,我们很乐意讨论。
我们确实有一名 GSoC 学生致力于为我们提供适当的 matplotlib 支持,因此在接下来的几个月内可能会有好消息。
我只是想知道 matplotlib 是否与 kivy 1.9.0 兼容,如果可能的话我该如何实现它?如果不支持,kivy有没有类似的东西?
我希望能够在我的 kivy 应用程序中使用我的程序中的这个特定代码:
def printPieChart(table, column):
if column == 6:
columnList = table.iloc[:, -1:].values.T.ravel()
else:
columnList = table.iloc[:, (column - 7): (column - 6)].values.T.ravel()
countedList = Counter(columnList)
#set up the size of the pie chart
fig = plt.figure(figsize=[10, 10])
ax = fig.add_subplot(111)
cmap = plt.cm.prism
#input variables for pie function
slices = [float(v) for v in countedList.values()]
colors = cmap(np.linspace(0., 1., len(slices)))
labels = [float(k) for k in countedList]
columnHeaders = list(table.columns.values)
#the pie chart
pie_wedge_collection = ax.pie(slices, colors = colors, labels = labels, labeldistance = 1.05, autopct = '%1.1f%%')
#get rid of the black outlines between the wedges and around the pie
for pie_wedge in pie_wedge_collection[0]:
pie_wedge.set_edgecolor('white')
ax.set_title(columnHeaders[column + 1])
如果我想为 matplotlib 做一个编译方法,会不会是这样?
#!/bin/bash
VERSION_matplotlib=${VERSION_matplotlib:-1.4.3}
DEPS_matplotlib=(numpy python dateutil pyparsing six linpng pytz freetype agg PyCXX qhull ttconv)
URL_matplotlib=http://pypi.python.org/packages/source/m/matplotlib/matplotlib-$VERSION_matplotlib.tar.gz
MD5_matplotlib=f43c20480a1673185afefc7d4848a1d2
BUILD_matplotlib=$BUILD_PATH/matplotlib/$(get_directory $URL_matplotlib)
RECIPE_matplotlib=$RECIPES_PATH/matplotlib
# function called for preparing source code if needed
# (you can apply patch etc here.)
function prebuild_matplotlib() {
true
}
function shouldbuild_lxml() {
if [ -d "$SITEPACKAGES_PATH/matplotlib" ]; then
DO_BUILD=0
fi
}
# function called to build the source code
function build_matplotlib() {
cd $BUILD_matplotlib
push_arm
export CC="$CC -I$BUILD_numpy/"
export LDFLAGS="-L$BUILD_numpy/numpy/.libs -L$BUILD_numpy/numpy/.libs -L$BUILD_numpy/.libs -L$BUILD_numpy/numpy -L$BUILD_numpy/numpy -L$BUILD_numpy/ $LDFLAGS"
export LDSHARED="$LIBLINK"
chmod +x $BUILD_numpy/numpy-config
export PATH=$PATH:$BUILD_numpy
#plus more for the other dependencies
try $HOSTPYTHON setup.py build_ext -I$BUILD_matplotlib
try find . -iname '*.pyx' -exec $CYTHON {} \;
try $HOSTPYTHON setup.py build_ext -v
try find build/lib.* -name "*.o" -exec $STRIP {} \;
export PYTHONPATH=$BUILD_hostpython/Lib/site-packages
try $BUILD_hostpython/hostpython setup.py install -O2 --root=$BUILD_PATH/python-install --install-lib=lib/python2.7/site-packages
unset LDSHARED
pop_arm
}
# function called after all the compile have been done
function postbuild_matplotlib() {
true
}
你可以从 kivy 脚本中调用 matplotlib,就像你通常那样,但是 kivy 没有内置的方式来显示绘图 - 你必须让 matplotlib 来渲染它们(例如,作为 png,或者你可以尝试 kivy 的实验性 svg 支持,但它可能有问题)然后将它们显示在图像小部件或类似的小部件中。
如果您想在 android 或 ios 上执行此操作,您需要 matplotlib 的编译方法,因为我认为我们还没有。我认为这应该不会太难,如果您有兴趣,我们很乐意讨论。
我们确实有一名 GSoC 学生致力于为我们提供适当的 matplotlib 支持,因此在接下来的几个月内可能会有好消息。