python - matplotlib: Change grid interval and specify tick labels -


I am trying to plot the plot in the disorganized plots, but I did not understand that I How do i go I want to:

(1) There are dotted grid at a gap of 5

(2) Only large tile labels are

(3) I

(4) "Count" within those grids,

I have probably tested such a duplicate, but I could not find it.

This is my code.

  import Matplotlibkpyplot Matplotlibkticker import MultipleLocator, as plt value in FormatStrFormatter key, Sort (data.items ()): X = value [0] [2] Y = value [0] [3] count = value [0] [4] fig = PLT.figer () ax = fig. Ada_sbplot (111) Kulhadhiknotet (calculated, Aksai = (x, y), size = 5) # overwritten and I only get the final data point Pltkclose () # fail without this, I assign "Bitmap "Error plt.suptitle ('number of numbers', fontsize = 12) ax.set_xlabel ('x') ax.set_ylabel plt.axes (). ( 'Y') set_aspect ( 'equal') plt.axis ([0, 1000, 0, 1000]) # This gives a gap 200 Main Loketr = Multiple Locator (20) Pramukfarmr = format Stiarformr ( '% d') small labels or = MultipleLocator (5) # I minor grid 5 and major grid I want to be for the 20 plt.grid () filename = 'C: \ Users \ owl \ Desktop \ Plot.png' plt.savefig (file Name, dpi = 150) Plt.close ()   

This is what I get.

This is what I get.

I have data There is a problem in overwriting the points, I too have trouble in it ... can anyone help me with this problem?

There are several problems with your code.

The first large numbers:

  1. You are creating a new figure and a new ax in every iteration of your loop - & gt; Put fig = plt.figure and ax = fig.add_subplot (1,1,1) outside of the loop

  2. Do not use the locks, call the function ax.set_xticks () and ax.grid () the right keyword.

  3. With plt.axes () you are creating a new axis again: small things: you plt.axis Like the syntax, matlab should not be mixed with ax.set_aspect ('equal')

    use () purpose Use the ax.set_xlim (a, b) and ax.set_ylim (a, b)

    with syntax to minimize it Should:

      plt fig = plt.figure () ax = fig.add_subplot (1,1,1) # major tick every 20, minor tick every 5 m Ajor_ticks = NP import as import matplotlib.pyplot as numpy. arange (0, 101, 20) minor_ticks = np.arange (0, 101, 5) ax.set_xticks (major_ticks) ax.set_xticks (minor_ticks, minor = true) ax.set_yticks (major_ticks) ax.set_yticks (minor_ticks, minor = right) # and related grid ax.grid (which = 'both') # or if you want differnet settings for the grid are: ax.grid (which = 'minor', alpha = 0.2) ax.grid (which = 'key ', Alpha = 0.5) plt.show ()   

    The output is:  Plot output

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -