How to decrease the spaces between two bars in matptolib?

56
April 29, 2019, at 7:00 PM

i am trying to get the bar graph using matplotlib.There are just 2 bars in the graph but the space between them is very large.I tried to decrease and increase width but it is just changing the bar width.

def evaluate_bar_graph(coherences, indices):
        assert len(coherences) == len(indices)
        n = len(coherences)
        x = np.arange(n)
        plt.bar(x, coherences, width=0.1, tick_label=indices, align='center')
        plt.xlabel('Models')
        plt.ylabel('Coherence Value')
        plt.show()

Answer 1

You can do it by choosing the position of your bar with y_pos and then rename the the x-axis. Like:

# space= 1 or 2
y_pos = [0, 1] # or y_pos = [0, 1]
# Create bars
plt.bar(y_pos, coherences)
# Create names on the x-axis
plt.xticks(y_pos, x)
# Show graphic
plt.show()
READ ALSO
Fluent-ffmpeg : Output with label 'screen0' doesnot exist in any diferent filter graph, or was already used elsewhere

Fluent-ffmpeg : Output with label 'screen0' doesnot exist in any diferent filter graph, or was already used elsewhere

I'm trying to take video frame by frame using fluent-ffmpeg, to create video masking and some kin of like experiment video editorBut when I do that by screenshots it says ffmpeg exited with code 1: Output with label 'screen0' does not exist in any defined...

40
throwing errors in express functional routes

throwing errors in express functional routes

I'm trying to work with pure functional route controller functions and I have an express route controller:

51
in ML how to detect specific image name from a set of different images [on hold]

in ML how to detect specific image name from a set of different images [on hold]

I have a set of images (each image can be anything)Then I print all the images and put them on the wall

44
How to run code daily, weekly, monthly in javascript

How to run code daily, weekly, monthly in javascript

I have an api end point where users hit with amount in data payloadI need to track users amount on daily weekly and monthly basis

39