Apache Commons альтернативы загрузки файлов

Я знаю, что это старая нить, но я приземлился здесь несколько раз через Google и думаю, что никакой ответ пока не удовлетворен. Попробуйте использовать одну из следующих функций:

def label_bar(ax, bars, text_format, is_inside=True, **kwargs):
    """
    Attach a text label to each bar displaying its y value
    """
    max_y_value = max(bar.get_height() for bar in bars)
    if is_inside:
        distance = max_y_value * 0.05
    else:
        distance = max_y_value * 0.01

    for bar in bars:
        text = text_format.format(bar.get_height())
        text_x = bar.get_x() + bar.get_width() / 2
        if is_inside:
            text_y = bar.get_height() - distance
        else:
            text_y = bar.get_height() + distance

        ax.text(text_x, text_y, text, ha='center', va='bottom', **kwargs)


def label_barh(ax, bars, text_format, is_inside=True, **kwargs):
    """
    Attach a text label to each horizontal bar displaying its y value
    """
    max_y_value = max(bar.get_height() for bar in bars)
    if is_inside:
        distance = max_y_value * 0.05
    else:
        distance = max_y_value * 0.01


    for bar in bars:
        text = text_format.format(bar.get_width())
        if is_inside:
            text_x = bar.get_width() - distance
        else:
            text_x = bar.get_width() + distance
        text_y = bar.get_y() + bar.get_height() / 2

        ax.text(text_x, text_y, text, va='center', **kwargs)

Теперь вы можете использовать их для обычных графиков:

bars = ax.bar(x_pos, values, width=0.5, align="center")
value_format = "{:.1%}"  # displaying values as percentage with one fractional digit
label_bar(ax, bars, value_format, is_inside=True, color="white")

или для графиков на горизонтальной панели:

horizontal_bars = ax.barh(y_pos, values, width=0.5, align="center")
value_format = "{:.1%}"  # displaying values as percentage with one fractional digit
label_barh(ax, horizontal_bars, value_format, is_inside=False, fontweight="bold")
21
задан Sean Patrick Floyd 14 January 2011 в 16:19
поделиться

2 ответа

Если у вас есть проблемы со временем или памятью, смотрели ли вы на потоковый API загрузки обычных файлов?

1
ответ дан 17 October 2019 в 02:38
поделиться

посмотрите эти настройки, по умолчанию ограничение составляет 8 МБ

upload_max_filesize
post_max_size
-2
ответ дан 17 October 2019 в 02:38
поделиться
Другие вопросы по тегам:

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