Pyplot line color and spacing/padding - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Pyplot line color and spacing/padding (/thread-3472.html) |
Pyplot line color and spacing/padding - metalray - May-26-2017 Dear Python Experts, I have prepared a chart and just some visual upgrades in mind I wonder why the chart goes beyond the maximum values given and why there is a gap in the left corner. fig1, ax1 = plt.subplots(figsize=(8, 4)) timeaxis = [2020, 2030, 2040, 2050, 2060] s1 = [2578,2819,3060,3301,3542] ax1.plot(timeaxis, s1, 'c-') ax1.set_xlabel('Year') # Make the y-axis label, ticks and tick labels match the line color. ax1.set_ylabel('No. of pages in Federal Law Gazette', color='black') ax1.tick_params('y', colors='black') ax1.spines['top'].set_visible(False) ax1.spines['right'].set_visible(False) fig1.tight_layout() plt.xticks(np.arange(min(timeaxis), max(timeaxis)+1, 10.0))Finally, when I try to write "gray" or give a HEX code instead of 'g' for green an error is thrown. How can I be more creative with the colors I use for the line chart? Many thanks for any hints. |