Let's say that a total charge Q is distributed nonuniformly throughout an insulating sphere of radius R. Trying to solve for the field everywhere can then become very difficult, unless the charge distribution depends only on r (i.e., it is still spherically symmetric).
How much charge is enclosed by a gaussian sphere of radius r < R if the charge per unit volume inside an insulating sphere is given by ρ(r) = cr?
The answer can be found by integrating over spherical shells. The volume of a shell of radius r and thickness dr is the surface area multiplied by the thickness:
dV = 4πr^{2} dr
The charge enclosed by such a shell is:
dq_{enc} = ρ dV = cr dV
Integrating from 0 to r gives:
q_{enc}  =  ∫  ρ dV  =  ∫ 

=  4πc  ∫ 

=  πc r^{4} 
What is c if the total charge on the sphere is Q? The enclosed charge is equal to Q when r = R, so:
q_{enc} = Q = πc R^{4}.
Therefore, c  = 

Two plots are shown on the graph above. One represents the charge enclosed by a gaussian sphere of radius r in the case of a uniform charge distribution, while the other represents the charge enclosed when the charge per unit volume inside the insulating sphere is ρ(r) = cr? Which plot is which?
This particular nonuniform distribution has less charge in the center and more concentrated toward the outside of the sphere than the uniform distribution has. Therefore the blue plot must be for the nonuniform distribution.